gpt4 book ai didi

git - cherry-pick 删除文件的提交

转载 作者:太空狗 更新时间:2023-10-29 14:47:36 52 4
gpt4 key购买 nike

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

$ 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 提交删除了这四个文件。如果文件存在(它们确实存在),那么应用提交的问题在哪里?

$ 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 来创建精心挑选的提交。

关于git - cherry-pick 删除文件的提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17923544/

52 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com