Git 拉取中止

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7034396/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:32:28  来源:igfitidea点击:

Git Pull Aborting

gitgit-pull

提问by sisdog

My colleague merged some change for a production hotfix into his local master branch and then did a push of master to our GitHub repository. Now I'm try to update my local master branch with his changes. When a do a "git pull origin" from the git console it seems like it going fine by showing all the files. But, near the end it just stops with the message "Aborting".

我的同事将生产修补程序的一些更改合并到他本地的 master 分支,然后将 master 推送到我们的 GitHub 存储库。现在我尝试用他的更改更新我的本地主分支。当从 git 控制台执行“git pull origin”时,通过显示所有文件似乎一切正常。但是,接近尾声时,它会随着消息“正在中止”而停止。

I have no idea what to do next. Help?

我不知道接下来要做什么。帮助?

UPDATE:So problem solved. The real root of the problem was that my colleague removed some entries from the .gitignore file in his branch that allowed several new files to come into his checkin. Since my local .gitignore was still ignoring those files, my local repo didn't think I had local working files to add to the index. I ended up deleting all the files and then the pull worked and brought them all in.

更新:所以问题解决了。问题的真正根源是我的同事从他的分支中的 .gitignore 文件中删除了一些条目,这允许几个新文件进入他的签入。由于我的本地 .gitignore 仍然忽略这些文件,我的本地存储库认为我没有将本地工作文件添加到索引中。我最终删除了所有文件,然后拉动工作并将它们全部引入。

I'm definitely going to be more careful editing the .gitignore file and checking it in. I now have some new appreciation for its affect on other developers.

我肯定会更加小心地编辑 .gitignore 文件并将其签入。我现在对它对其他开发人员的影响有了一些新的认识。

采纳答案by Stefan Kendall

He probably put the commit somewhere in the existing commit tree, rather than on top of it.

他可能将提交放在现有提交树的某个位置,而不是放在它的顶部。

Try this:

尝试这个:

git fetch origin
git rebase origin/master

And if that doesn't work, just create a local branch of origin, cherry-pick your local commits onto it, reset master before whatever commit he merged, and then merge your local branch onto master.

如果这不起作用,只需创建一个本地分支origin,将您的本地提交挑选出来,在他合并的任何提交之前重置 master,然后将您的本地分支合并到 master 上。

My guess is that his push involved a --forceat some point to avoid a not a fast-forward commitmessage. You don't want to do that, in the future.

我的猜测是他的推送--force在某些时候涉及到避免not a fast-forward commit消息。你不想这样做,在未来。

回答by sisdog

The root of the problem was that my colleague removed some entries from the .gitignore file in his branch that allowed several new files to come into his checkin. Since my local .gitignore was still ignoring those files, it didn't think I had local working files to add to the index. I ended up deleting all the files and then the pull worked and brought them all in.

问题的根源在于我的同事从他的分支中的 .gitignore 文件中删除了一些条目,这允许几个新文件进入他的签入。由于我的本地 .gitignore 仍然忽略这些文件,它认为我没有将本地工作文件添加到索引中。我最终删除了所有文件,然后拉动工作并将它们全部引入。