“git pull”命令像“svn update”一样工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1309878/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
a 'git pull' command works like 'svn update'?
提问by n179911
I am using 'git' to checkout chromium code by following this document: http://code.google.com/p/chromium/wiki/UsingGit
我正在使用“git”通过以下文档检查铬代码:http: //code.google.com/p/chromium/wiki/UsingGit
And it said 'Run git pull or whichever command is appropriate to update your checkout. '.
它说'运行 git pull 或任何适合更新结帐的命令。'。
But the problem I run into is when I have local changes in my git working directory and then I run 'git pull'. It said something like XXX file can't get update (I made a change locally). I force 'git pull' to work by removing my change 'git checkout -- XXX.cpp'
但是我遇到的问题是当我的 git 工作目录中有本地更改然后我运行“git pull”时。它说 XXX 文件无法更新(我在本地进行了更改)。我通过删除我的更改“git checkout -- XXX.cpp”来强制“git pull”工作
Is there a way to get 'git pull' to merge automatically if possible (the svn update equivalent)?
如果可能的话,有没有办法让“git pull”自动合并(svn update 等价物)?
Thank you.
谢谢你。
采纳答案by William Pursell
If you want a pull to merge with changes you have made locally, you will need to commit your changes to your local directory first. Or, stash your changes, then pull, then re-apply your stash.
如果您希望 pull 与您在本地所做的更改合并,则需要首先将更改提交到本地目录。或者,存储您的更改,然后拉取,然后重新应用您的存储。
回答by user160223
I think what you want to do is:
我想你想做的是:
- commit all changes to your local repository
- do a 'git rebase'.
- 将所有更改提交到本地存储库
- 做一个'git rebase'。
This is slightly better than 'svn update' in my opinion, because it will first change your local working copy to the way it was the last time you pulled or rebased from the remote, then fetch and apply new changes from the remote, and then reapply your locally committed changes. If there's a conflict between your changes and the remote changes, you'll need to resolve them and follow the prompts to continue the rebase operation.
在我看来,这比 'svn update' 稍微好一点,因为它会首先将您的本地工作副本更改为上次从远程拉取或重新定位时的方式,然后从远程获取并应用新的更改,然后重新应用您本地提交的更改。如果您的更改和远程更改之间存在冲突,您需要解决它们并按照提示继续 rebase 操作。
This way the changesets should be applied in the right order.
这样,变更集应该以正确的顺序应用。