How do I make my branch the same as its corresponding remote branch?
This post follows my previous post on git pull: Git: What EXACTLY does "git pull" do?
Let's say that I want to do a "git pull" to a specific branch, and I want my local copy of that branch to be IDENTICAL to the remote copy of the remote. How to do it?
+3
source to share
4 answers
Once selected with git fetch
, will git reset @{u}
set the branch to point upstream. git reset --hard @{u}
will additionally check that the revision version continually discards any changes to tracked files in your working directory .
If you also want to discard untracked files, you can do this in bash like this:
bash -c '
GLOBIGNORE=.:..
shopt -s dotglob extglob
rm -rf !(.git)
git reset --hard @{u}'
0
source to share