Reputation: 777
I keep my vim configuration files on github to keep them synched across multiple machines. Once in a while I use a machine I haven't used in a while and the vim files are way out of synch. If I simply
git pull
from remote the directory becomes messy since old files (or renamed files) not present anymore in the official remote stay put. So what I typically do is to delete everything and git clone from scratch.
Is that the best approach? Ideally I would like to have a command
git xxx
which delete/replace everything making a perfect replica of the remote
Upvotes: 0
Views: 94
Reputation: 181745
git pull
will merge in the changes from upstream. Then type git reset --hard
to revert all modified files to their version as present in HEAD.
There is some risk of merge conflicts. Alexander's answer avoids those.
This will not remove any files that are unknown to Git. For that, shout git clean
.
Upvotes: 1
Reputation: 10458
git fetch origin
git reset --hard origin/master
Where origin
is the remote, and master
is the remote branch you want to your local working copy to be in sync with. Note that these commands replace any local files (including changes) with the remote state. That means that there will be no merge conflicts. It mimics your delete-and-reclone workflow.
Upvotes: 4