如何使用Git和命令行合并期间保留本地文件或远程文件? [英] How to keep the local file or the remote file during merge using Git and the command line?
问题描述
我知道如何使用vimdiff合并修改,但是,假设我只知道整个文件很好保留或丢弃,我该怎么做?
我不想为他们每个人打开vimdiff,我改变了想要一个说'keep local'或'keep remote'的命令。 b:b
EG:我将文件标记为已更改,因为有人在窗口中打开它,更改了EOL,然后进行了提交。合并时,我想保留自己的版本并放弃他。
我也有兴趣反过来:我搞砸了大部分时间,想要接受远程文件,放弃我的更改。
您也可以这样做:
git checkout - 他们的/ path / to / file
保留远程文件,和:
git checkout --ours / path / to / file
保留本地文件。
然后 git add
他们,一切都完成了。
很简单,不是吗? :)
I know how to merge modification using vimdiff, but, assuming I just know that the entire file is good to keep or to throw away, how do I do that?
I don't want to open vimdiff for each of them, I change want a command that says 'keep local' or 'keep remote'.
E.G: I got a merge with files marked as changed because somebody opened it under windows, changing the EOL, and then commited. When merging, I want to just keep my own version and discard his.
I'm also interested in the contrary: I screwed up big time and want to accept the remote file, discarding my changes.
You can as well do:
git checkout --theirs /path/to/file
to keep the remote file, and:
git checkout --ours /path/to/file
to keep local file.
Then git add
them and everything is done.
Easy, isn't it? :)
这篇关于如何使用Git和命令行合并期间保留本地文件或远程文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!