After running git fetch
, you can force master
to change to where origin/master
is:
git branch -f master origin/master
Then you can check it out:
git checkout master
Which will be at the state of origin/master
and you will not pass by the intermediate state it was before.
Here is a brief example (I am checked out on test
and change master
to the same place as test
):
> git log --graph --oneline
* d97b1f8 (HEAD -> test) - tata (1 second ago)
* e680fb5 - toto (9 seconds ago)
* 4515586 (master) - bar (24 seconds ago)
* e241705 - foo (28 seconds ago)
> git branch -f master test
> git log --graph --oneline
* d97b1f8 (HEAD -> test, master) - tata (9 seconds ago)
* e680fb5 - toto (17 seconds ago)
* 4515586 - bar (32 seconds ago)
* e241705 - foo (36 seconds ago)