how to checkout a specific commit from git

git checkout <id>

should do the trick. Where 'id' is the specific commit you want to get.


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

Tags:

Git

Bitbucket