The requirements for the task I want to do is as follows:
ie I have files a , b , and c in my master branch.
I have files a , b , c , and d in my local directory.
Files b and c are out of date in my local directory, so I want to overwrite them with b and c from the master branch.
However, while doing so, I do not wish for file d to be erased.
(Note: I do not wish to just update b and c manually because, in my case, I am working with many files. So, I don't want to pull all of those files manually.)
Also, to be more clear, I wish to do this from the command line. (I'm using the terminal on my Mac if that helps.)
Pull master and accept --theirs
if conflict occurs.
$ git pull origin master -s recursive -X theirs
Alternative:
$ git pull origin master
$ git checkout --theirs -- . # accept 'remote/master' changes
You'd probably want to stash changes and then unstash once you've pulled.
In short it's pretty much:
git stash
git pull
git stash apply
Further information about stashing can be found here
The above is for if the files you don't want to erase haven't been committed yet. For files that have been committed but not pushed to origin
then git pull --rebase
might be what you're after.
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.