GIT 远程和本地存储库上的不同文件
我的 GIT 存储库中有一个文件,我通过 github.com 编辑器更改了该文件。
现在,我也在本地存储库中更改了此文件。
解决这个问题的常见工作流程是什么?我现在不能拉或推。
I have a file in my GIT repository that I changed through the github.com editor.
Now, I went and change this file in my local repository aswell.
What is a common workflow for solving this? I cannot pull or push now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
现在我明白了,你是说 GitHub 和本地都有更改。我将假设您的本地更改已提交 - 如果没有,您应该提交它们或使用 git reset --hard HEAD 丢弃它们。
原则上 git pull 应该将远程更改拉下来并合并它们,但这不起作用。如果 git 抱怨合并冲突,那么您应该手动解决它们,提交结果,然后将其推送。
如果发生了奇怪的事情,你可以尝试同样的方法。首先获取远程跟踪分支中的远程更改(即不在您的工作目录中),
git pull
可能会为您完成此操作(使用gitk --all
来查出)。如果没有,请尝试使用 git-fetch 来尝试获取更多内容)。当您在远程跟踪分支中拥有所需的内容时,您可以手动执行 git merge 。(抱歉,如果这不是很清楚,但由于我不知道你的确切错误,所以我必须猜测)。
Now I do understand, you're saying have changes both on GitHub and Locally. I am going to assume your local changes are committed - if not, you should either commit them or throw them away using
git reset --hard HEAD
.In principle
git pull
should have pulled the remote changes down and merged them, but that is not working. If git is complaining about merge conflicts then you should resolve them by hand, commit the result and then push it up.If something stranger has happened, you can try the same approach. First grab the remote changes in a remote-tracking branch (i.e. not in your working directory),
git pull
will probably have done this for you (usegitk --all
to find out). If not, play around withgit-fetch
to try and grab more stuff). When you have what you want in a remote tracking branch, you can do agit merge
by hand.(Sorry if this is not very clear, but since I don't know your exact errors, I have to guess).
编辑文件,在 Github 中提交更改。
或
在本地仓库中
Edit file, commit changes in Github.
or
in local repo