My code isn't working and it seems I have merged a wrong piece of code in my master
branch. I am unable to pin point the issue and thus I want to pull specific commits one by one to find out which version was working just before the wrong commit.
How could I pull a specific commit? Eg, On Bitbucket, I see a merge with id 9ce920d
on branch test
but I don't know how to pull this merge.
The question has wrong terminology. You cannot pull a commit, you can only checkout a commit. Pulling a commit would defy the whole branch/commit structure saving memory. You pull all commits in a branch or repository, and if you want to check out a specific one, then well, check it out:
git checkout 9ce920d
You will be in headless mode (no pointer to the commit, even if you have branches pointing to them - you have to check them out explicitly!), so you may want to create a branch if you want to mess around:
git checkout -B mess_around_branch
For posterity, OP actually wanted to discard all commits from the latest commit on their branch to a specific commit before. To do this from your branch hit:
git reset 9ce920d
which will discard all commits, but leave the files as they were, allowing you to decide if you wish to retain some of the changes. If you really want to lose everything:
git reset --hard 9ce920d
git checkout <id>
should do the trick. Where 'id' is the specific commit you want to get.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With