I created a local repository and made about eight commits. I have not pushed anything to a remote repository. Then I realized that I should have put the last three commits into a separate branch so I created a new branch at the sixth commit and set the master to the fifth commit. There were a couple of changes that had not been committed. Now it appears that I have only the sixth commit in the branch and the last two commits do not show separately on the branch or the continuation of the master branch, so I'm confused as to what happened to them. I did not do a stash before creating the branch or resetting the master.
I believe I need to undo the branch/master changes and start over with all commits in the master. I did create a stash after the fact but am now gun shy about losing the missing commits.
Please Help!
Gary
Don't worry, they only disappeared because the only branch that was pointing to the 8th commit was master and after you reset it to the 5th commit there was nothing pointing to the last commit any more therefore it doesn't show up anymore in ST but they still exist.
What you need to do is find out what the commit hashes of the missing commits are (you can do this using the command:
git reflog
and then it's up to you but you can either cherry pick them back into a branch individually via command line (I can't see a way to do this in ST) or easier maybe is to just create a new branch/tag where that last commit was.
In ST it looks like you can create a new tag and specify a commit hash, so if you use the hash of the 8th commit it should create a new tag at that spot and then at least you can see them again and do whatever you want with them after that .
Good answer! I'd just add: see the example at https://www.atlassian.com/git/tutorials/rewriting-history/git-reflog
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.