This post follows my previous post about git pull: Git: What does EXACTLY "git pull" do?
Let's say that I want to do "git pull" to a certain branch and I want that my local copy of this branch will be IDENTICAL to the remote copy of the remote one. How to do it?
Assuming you're already on the branch in question (and it's tracking the upstream correctly), the simplest way is
git fetch && git reset --hard FETCH_HEAD
This uses the special FETCH_HEAD
ref so you don't need to type the upstream branch name or anything else.
This should do the trick:
git fetch
git reset --hard origin/{insert branch name}
git clean -fd
If you want it to really be the same including removing the gitignored stuff, use git clean -fdx
.
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