How to revert to a earlier local commit in Xcode 7 in GIT?

What is the best way to do this?

I know you can see the changes between commits in the Version Editor, but I can't really go back to a local commit I did previously.


I'm basically trying to replicate Snapshot functionality, which unfortunately was removed in XCode 7.


Thanks.

You could create a branch from the old commit and work from there

git checkout -b <branch_name> <commit>


Or to completely discard the changes you can use "git reset ..." also from the command line. There are several options (--hard, --soft, etc.) depending on exactly what you want to do so I recommend doing some web searches on the subject.


Whichever way you do it, you most likely will have to use the command line.

You have two actions in Source Control menu.

Source Control>Discard All Changes...

or

Source Control>Discard Changes in Selected Files...

Do they not fulfill your requirement?

Let's say I have 5 local commits

- Commit 1

- Commit 2

..

- Commit 5


At this point when I'm working, I'd like to go back to commit 2.

How would I do so? This was so easy using snapshots in previous versions of XCode.


Discard changes only goes back to commit 5, right?

Apple should allow XCode to do this.... ? Else why remove the snapshot functionality?

Sorry, I have missed `earlier` which you clearly noted... (And I couldn't have utilized old Snapshot feature.) Then you need to use command-line git, I think, as junkpile wrote.

And I would also welcome if this sort of functionality will be built in Xcode.

You can do it with Xcode, but one by one for individual files. Not for the whole project at once. Select View > Version Editor > Show Version Editor. (I'm in Xcode 7). On version editor split view, there is a timeline icon at middle bottom. You can select any previously committed version and compare and/or revert to it. http://www.raywenderlich.com/51351/how-to-use-git-source-control-with-xcode-in-ios-7 page has more detail.

Wow, if that is the best xcode can do, this source control feature is only half baked. I have exactly the same situation with OP and was hoping I can just - in a single click of a button - go back to an earlier commit to create a new branch as what I experimented with currently is not working the way I want.


Thanks for the info though. If the version I want to discard has new files not in the earlier committed version I wish to revert to, how do I discard those files? Also what about storyboard changes? Thanks

Exactly the same issue.


I have 120 commits changing code over to SWIFT3 ... one of them has cause issues, and I can't work out if it just one of the Unfixed SWIFT3 bugs, or it is something in my own code.


What is the point of being able to commiting-mutple-files at once in Xcode's code management system .. if you are not able to Uncommit the multiple-file-change?


If Xcode is going to fix this (rather basic functional Bug), may I suggest that they put up a large Banner when you are commiting, to say "Note: Committing files here doesn't actually do anything to help you recover back to this safe point, you'll need to learn low level commands and spend days hoping that everything works again in this project."


Is Apple is trying to push people to make Hourly snapshots of their entire code repositories .. just incase you need to revert back to see the POINT IN TIME that a problem was introduced.


AJ

Here is the workaround that I am now using:


1) Use Source control : History : Find the Dates & Times of all the commits.


2) Use TimeMachine : Find the first SNAPSHOT after the XCode Commit time


3) Restore the enclosing Source code directory structure : Keep Both : New directory is called 'Original' (perhaps Apple should called it 'Restored'?)


4) Open 'Restored' Project in Xcode : Back out All changes in Source Control.


BAM ... you now have the sort of functionality of a high-tech Code Management System (like VAX CMS ... from the 1970's).


Please Apple ... put this functionality back into Xcode.....

I've just ran into this issue.


Honestly, this basically makes the Source Control feature entirely pointless. What's the point of committing changes if I can't go back to previous commits?


Apple - When are you going to fix this?

go to version editor: "alt + shift + command + enter", underneeth the editor you can choose the version you want and then discard changes either individually or all together via source controll menu

What do you mean by " or all together via source controll menu"?


Suppose in Ippier's exampler earlier in the thread, suppose one wants to revert to Commit 2 and the project contains 100 files. How do you select those 100 files and revert them all together as you have said?

How to revert to a earlier local commit in Xcode 7 in GIT?
 
 
Q