拉取是不可能的,因为你有未合并的文件,git stash 不起作用。不想提交



我只想拉。我有更改要忽略,我的Gemfile和Gemlock文件,我很乐意覆盖他们,只是拉。我试着把我的改变藏起来,但这对我来说不起作用。我该怎么办?

git pull
M   Gemfile
U   Gemfile.lock
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
~/projects/sms/apps2/apps2_admin(apps2)$ git stash save "saved"
Gemfile.lock: needs merge
Gemfile.lock: needs merge
Gemfile.lock: unmerged (4ea16799dba7bfe1db28adecf36dee1af5195c1a)
Gemfile.lock: unmerged (e77439c9f86d1d0eda7ae0787e3e158f90959e68)
Gemfile.lock: unmerged (d690d3860db1aa8e46c1bb2f4de3e52a297b5c26)
fatal: git-write-tree: error building trees
Cannot save the current index state
~/projects/sms/apps2/apps2_admin(apps2)$ git pull
M   Gemfile
U   Gemfile.lock
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
git fetch origin
git reset --hard origin/master
git pull

解释:

    Fetch将从另一个存储库下载所有内容,在本例中,是标记为"origin"的存储库。
  • Reset将丢弃更改并恢复到存储库"origin"中的上述分支"master"。
  • Pull将从远程存储库获取所有内容并进行集成。

您可以使用git checkout <file>来签出文件的已提交版本(从而丢弃您的更改),或者使用git reset --hard HEAD来丢弃所有文件的未提交更改。

我尝试了这两种方法,但仍然因为冲突而失败。在我忍无可忍的时候,我在另一个位置克隆了master,将所有内容复制到另一个分支并提交。让我继续。"-X他们的";选项应该为我做这些,但是它没有。

git merge -s recursive -X their master

错误:'合并'是不可能的因为您有未合并的文件。提示:在工作树中修复它们,提示:然后使用'git add/rm '作为提示:适当标记下定决心,做出承诺,提示:或者使用'git commit -a'。致命的:由于未解决的冲突而退出。

我有同样的错误,我解决它与:git merge -s recursive -X theirs origin/master

最新更新