简体   繁体   中英

Git updating a stale local repo

I've tried searching for an elegant way (ie that doesn't involve deleting the local directory and cloning again) to update a severely stale local repo from a remote repo using git, but haven't found a good answer. The command I'm looking for would basically resolve any conflict by using whatever the remote repo says and deleting local files if need be (in case they no longer exist in the remote repo) and ignoring any and all chancges I might've made to tracked files.

You could:

So you don't have to deal with "merge conflicts": it is sort of a global reset (proceed with caution if you had any work you would like to keep, which doesn't seem to be the case from your question).

The OP Syrahn went for a simpler way:

at that point I just rm -Rf the dir and clone from scratch.
Git really needs a --theirs --all --force type of thing.

Note that there are ways to emulate "theirs" option, even if " Git merge -s theirs: Simply? " explains why it isn't very visible: see " git command for making one branch like another "

Try using these commands:

git fetch
git reset --hard origin/master

This will force your local branch to match the branch on the remote while throwing away any changes. Note however you will need to execute the second step for each branch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM