简体   繁体   English

Git:修复无用错误,以免重蹈覆辙

[英]Git: fix noobish mistake to avoid rebase hell

I'm a bit new with git, and decided that I would jump right into it rather than giving myself a proper tutorial. 我对git有点陌生,因此决定直接加入它,而不是给自己一个适当的教程。 After a month of working on a project, I've gotten myself into a little trouble. 在一个项目上工作了一个月之后,我陷入了麻烦。 I decided at one point in time that I didn't like how a particular piece of code was turning out, so at that point, B, I branched to E, deleted the offending file, and recreated it as a whole new file. 我在某个时间点决定不喜欢特定代码的结果,因此在那一点上,我分支到了B,删除了有问题的文件,并将其重新创建为一个新文件。 Obviously the best thing to do would have been to git rm instead of just deleting the file... I now need to rebase E to branch off of C, but am not sure how to manage that, because of conflicts with the rebase, since the file changes in both branches. 显然,最好的办法是使用git rm而不是仅仅删除文件...现在我需要将E重新设置为基于C的分支,但是由于与重新设置存在冲突,因此我不确定如何管理它,因为文件在两个分支中都更改。 My goal is basically to have the branch starting at E continue with the new file, but to incorporate the changes of C into the new branch. 我的目标基本上是让以E开头的分支继续新文件,但将C的更改合并到新分支中。 Any help in figuring out how to manage rebasing this, would be greatly appreciated. 我们将不胜感激,以帮助您弄清楚如何管理此基准。

A -> B -> C -> D
     \
       E -> F -> G

Your concluding statement tells me that what you are looking for is to merge the specific file in C or even better in D with the same file in G. This way you will have the new file as it has progressed from E to G including the changes you made in C which I presume are also in D. 您的结论声明告诉我,您正在寻找的是将C中的特定文件或D中的更好文件与G中的相同文件合并。这样,您将拥有从E到G的新文件,包括更改你以C制成的,我猜也是在D中。

Merging specific files between branches is possible. 可以在分支之间合并特定文件。 As I am not very experienced doing this I will refer you to a couple of links that describe how you can do it: 由于我的经验不是很丰富,因此我将向您介绍一些链接,这些链接描述了如何执行此操作:

http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/ http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/

How do I merge changes to a single file, rather than merging commits? 如何将更改合并到单个文件,而不是合并提交?

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM