我试图在git中精挑细选一个commit,它添加了一堆文件,但也修改了我的分支中尚不存在的文件。
存在这样的冲突:要添加的文件都是暂存的,而在提交中更改但在分支中尚不存在的文件未暂存,并被列为:
deleted by us: app/changed_file.rb如果我只提交暂存的文件,当changed_file.rb最终合并到分支中时,会不会出现问题?
发布于 2013-03-29 07:33:56
https://www.kernel.org/pub/software/scm/git/docs/git-cherry-pick.html
Cherry pick创建新的提交,所以如果省略了分支中不存在但存在于分支中的文件,那么最终什么都不会发生。
mkdir test && cd test && git init && touch foo.txt
git add foo.txt && git commit -m "Init repo"
git branch test && git checkout test && vi foo.txt
git add foo.txt && git commit -m "Changed foo on branch test"
git checkout master && touch bar.txt
git add bar.txt && git commit -m "Create bar.txt"
vi bar.txt
touch baz.txt && git add . && git commit -m "Will be cherry picked"
git checkout test && git cherry-pick bfd1b58
git rm bar.txt && git commit
git checkout master && git merge test作为ls的结果:bar.txt baz.txt foo.txt
发布于 2013-05-14 21:10:44
如果不需要,您可以简单地将该文件从提交中删除。
git rm file_name
git提交
-here确保提交消息包含Change ID :行作为最后一段
git推送源头:refs/for/branch_name
这样你不会得到任何冲突,这将使你的合并下次更容易..
https://stackoverflow.com/questions/15690261
复制相似问题