Git pull till a particular commit

git pull is nothing but git fetch followed by git merge. So what you can do is

git fetch remote example_branch

git merge <commit_hash>


First, fetch the latest commits from the remote repo. This will not affect your local branch.

git fetch origin

Then checkout the remote tracking branch and do a git log to see the commits

git checkout origin/master
git log

Grab the commit hash of the commit you want to merge up to (or just the first ~5 chars of it) and merge that commit into master

git checkout master
git merge <commit hash>

You can also pull the latest commit and just undo until the commit you desire:

git pull origin master
git reset --hard HEAD~1

Replace master with your desired branch.

Use git log to see to which commit you would like to revert:

git log

Personally, this has worked for me better.

Basically, what this does is pulls the latest commit, and you manually revert commits one by one. Use git log in order to see commit history.

Good points: Works as advertised. You don't have to use commit hash or pull unneeded branches.

Bad points: You need to revert commits on by one.

WARNING: Commit/stash all your local changes, because with --hard you are going to lose them. Use at your own risk!

Tags:

Git

Github