Reputation: 672
I have these commits on my project:
I wanted to see something in Commit 3, so on source control I choosed "Checkout" on Commit 3. It revert to Commit 3.
But now in the list of commits I can't see Commit 4 and Commit 5 anymore! Does it mean I lost all my work? Is it really so simple to lose everything?
Upvotes: 0
Views: 550
Reputation: 20088
If all you want to do is see something in Commit 3, double-click Commit 3 in the list of commits. Xcode's editor will show you a list of all the files you modified in that commit. Select a file to see the changes you made to that file.
Checking out commits is a bad idea. When you check out a commit, you end up with a detached head, which means the repository has no current branch. With no current branch, you are going to run into problems committing to the repository. A better alternative to checking out a commit is to create a branch off that commit.
To get back to Commit 5, check out the branch that has Commit 5.
Upvotes: 0
Reputation: 3256
No, you did not lose all your work. No it is not that simple. Once you commit something, it should be very easy to recover it.
You can always go to your Version Control platform, look the commit history on a branch, pick a commit ID and revert to it.
You can try: git reflog
and get the ID.
Then you can checkout to that ID, check on how to do it on this answer: https://stackoverflow.com/a/34777222/8869493
Upvotes: 1