最新消息:20210917 已从crifan.com换到crifan.org

[已解决]git stash时出错:needs merge fatal git-write-tree error building trees

Git crifan 10228浏览 0评论

git stash出错:

licrifandeMacBook-Pro:SalesAppiOS crifan$ git status
On branch master
Your branch is up-to-date with ‘origin/master’.
Unmerged paths:
  (use “git reset HEAD <file>…” to unstage)
  (use “git add/rm <file>…” as appropriate to mark resolution)
    deleted by them: SalesApp/RegisterView.swift
Changes not staged for commit:
  (use “git add <file>…” to update what will be committed)
  (use “git checkout — <file>…” to discard changes in working directory)
    modified:   SalesApp/EditInfoView.swift
    modified:   SalesApp/EditInfoViewController.swift
    modified:   SalesApp/GesturePasswordViewController.swift
    modified:   SalesApp/LoginRegisterViewController.swift
    modified:   SalesApp/MyViewController.swift
    modified:   SalesApp/ServerApi.swift
no changes added to commit (use “git add” and/or “git commit -a”)
licrifandeMacBook-Pro:SalesAppiOS crifan$ git stash
SalesApp/RegisterView.swift: needs merge
SalesApp/RegisterView.swift: needs merge
SalesApp/RegisterView.swift: unmerged (e8256c49ef03c6c2e7f78d852de8927f8dbaef4f)
SalesApp/RegisterView.swift: unmerged (525fb1f763c4932d2c919858416db20d96ee787d)
fatal: git-write-tree: error building trees
Cannot save the current index state
licrifandeMacBook-Pro:SalesAppiOS crifan$ 

搜:

git stash needs merge

看到提示了:

git add/rm <file>…

去删除:

此处不再用的那个文件

licrifandeMacBook-Pro:SalesAppiOS crifan$ git rm SalesApp/RegisterView.swift
SalesApp/RegisterView.swift: needs merge
rm ‘SalesApp/RegisterView.swift’
licrifandeMacBook-Pro:SalesAppiOS crifan$

好像没有成功?

的确已经删除了:

licrifandeMacBook-Pro:SalesAppiOS crifan$ git rm SalesApp/RegisterView.swift
SalesApp/RegisterView.swift: needs merge
rm ‘SalesApp/RegisterView.swift’
licrifandeMacBook-Pro:SalesAppiOS crifan$ git status
On branch master
Your branch is up-to-date with ‘origin/master’.
Changes to be committed:
  (use “git reset HEAD <file>…” to unstage)
    deleted:    SalesApp/RegisterView.swift
Changes not staged for commit:
  (use “git add <file>…” to update what will be committed)
  (use “git checkout — <file>…” to discard changes in working directory)
    modified:   SalesApp/CustomerTrafficReportViewController.swift
    modified:   SalesApp/EditInfoView.swift
    modified:   SalesApp/EditInfoViewController.swift
    modified:   SalesApp/GesturePasswordViewController.swift
    modified:   SalesApp/LoginRegisterViewController.swift
    modified:   SalesApp/MyViewController.swift
    modified:   SalesApp/ServerApi.swift

然后再去git stash就可以了:

licrifandeMacBook-Pro:SalesAppiOS crifan$ git stash
Saved working directory and index state WIP on master: 90dd609 add and support change login password
HEAD is now at 90dd609 add and support change login password

[总结]

此处是由于:

之前有个已经通过文件夹中删除掉的文件

-》没有通过git命令,或者是Xcode

-》导致git没有记录

-》所以此处再去git stash,就提示需要合并,是因为有改动(删除文件的改动)没有合并进来

-》用git rm xxx,删除对应的文件,即可正常后续的git stash操作

转载请注明:在路上 » [已解决]git stash时出错:needs merge fatal git-write-tree error building trees

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
105 queries in 0.219 seconds, using 22.98MB memory