樱桃选择删除文件的提交 [英] cherry picking a commit that deletes files

查看:147
本文介绍了樱桃选择删除文件的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要合并多个存储库(每个存储库都从 TFS 转换而来)。为此,我使用git cherry-pick命令,该命令适用于某些提交,但不适用于其他提交。

I need to merge several repositories (each of them was converted from TFS) into one. To do that I use git cherry-pick command, which works for some commits, but not for others:

$ git status
# On branch master
nothing to commit, working directory clean
$ git diff-tree --no-commit-id --name-only -r e2d8405
Libraries/IFileTransformer/ITransformer.cs
Libraries/IFileTransformer/IFileTransformer.csproj
Libraries/IFileTransformer/IFileTransformer.csproj.vspscc
Libraries/IFileTransformer/Properties/AssemblyInfo.cs
$ git cherry-pick e2d8405
error: could not apply e2d8405... TFS changeset 2836
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
$ git status
# On branch master
# You are currently cherry-picking.
#   (fix conflicts and run "git commit")
#
# Unmerged paths:
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#       deleted by them:    Libraries/IFileTransformer/ITransformer.cs
#       deleted by them:    Libraries/IFileTransformer/IFileTransformer.csproj
#       deleted by them:    Libraries/IFileTransformer/IFileTransformer.csproj.vspscc
#       deleted by them:    Libraries/IFileTransformer/Properties/AssemblyInfo.cs
#
no changes added to commit (use "git add" and/or "git commit -a")
$

如何找出这里出了什么问题?谁是他们?在我看来,e2d8405提交删除了这四个文件。如果这些文件存在(他们这样做),那么应用提交的问题在哪里?

How do I find out what is wrong here? Who is "them"? It seems to me that the e2d8405 commit deletes the four files. If the files exist (and they do) then where is the problem with applying the commit?

$ git checkout e2d8405^
Note: checking out 'e2d8405^'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 48b5b2f... TFS changeset 2835   renamed namespace installutils to
 utils
$ md5sum IFileTransformer.csproj
9f9851dc9db3bddd1e6920631fa14e8b *IFileTransformer.csproj
$ git checkout master
Previous HEAD position was 48b5b2f... TFS changeset 2835   renamed namespace ins
tallutils to utils
Switched to branch 'master'
$ md5sum IFileTransformer.csproj
9f9851dc9db3bddd1e6920631fa14e8b *IFileTransformer.csproj


推荐答案

虽然该提交会删除这些文件,但您的修改不存在于已删除的版本中。由于这里存在冲突,在修改文件的分支和删除它们的分支之间,您需要通过指出您很高兴放弃更改并应用删除( git rm ... )。完成之后, git commit 来创建樱桃挑选的提交。

Although that commit deletes those files, you have modifications that weren't present in the deleted version. As there is a conflict here, between the branch that modifies the files and the branch that deletes them, you will need to resolve it by indicating that you're happy to discard the changes and apply the delete (git rm ...). Once you've done that, git commit to create the cherry-picked commit.

这篇关于樱桃选择删除文件的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆