无法理解Git分支,合并和重新绑定 [英] Unable to understand Git branch, merge and rebase

查看:142
本文介绍了无法理解Git分支,合并和重新绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道线程,它表示rebase是对teamMates的小改动,而对于大的改变进行合并。



我在三个队友中保留三个队友在以下目录结构中我们都有相同的初始代码:

 项目
| - 我
| - myTeamMate1
| - myTeamMate2

分支不在同一个Git中。这意味着我不能使用rebase和merge。
我已经使用vimdiff在teamMates之间同步更改。但是,这是非常耗时的。



我没有成功尝试使所有分支在一个Git下的目录结构:

 项目
| - I - myTeamMate1 - myTeamMate2

然而,我为我和我的队友运行了clone命令: p>

  git clone< url> 

并且在为我的队友运行第二个克隆后收到错误消息

 致命:目标路径'dotFiles'已经存在并且不是空目录。 

应由3人组成的团队使用哪种目录结构,例如我可以使用 rebase merge 命令?

解决方案

只是一些其他的想法来完成塞缪尔的答案。




  • 与SVN不同,分支和目录在Git中完全不相关:拥有3个分支(每个团队成员一个分支)并不意味着3个目录。这不是你在你的问题中的含义(因为你的目录实际上是3个Git仓库的根目录),但我更愿意明确提及它以防万一;)

  • p> Git是DVCS,3个存储库可以在任何地方(不在同一台计算机上的3个目录中)。如果它们可通过UNC路径( \\desktop\path\to\repo )到达,则可将它们指定为远程。


  • Git 克隆确实允许获得对远程分支的引用,但不会创建跟踪本地分支,从而让您获得同事的工作。 ruby模块远程分支可以提供帮助。


  • 重新发布,因为它会重写您的SHA-1分支(因为你在另一个分支上重放你的提交):如果你的队友在你的分支上进行合并,他们将不得不每次都合并你的提交,甚至是那些已经合并的提交!

    在这种情况下,最好有2个分行:


    • 一个工作分行为了您的开发和重组(即使整合同行的作品,尽管该操作可以在其自己的分支中完成)

    • 发布公共分支,on您只合并稳定的工作,然后可以将其他远程存储库用作合并源。



I know the thread which says that rebase is for small changes of teamMates, while merge for large changes.

I keep three Gits of three teammates in the following directory structure where we all have the same initial code:

project 
      | - I
      | - myTeamMate1
      | - myTeamMate2

The branches are not in the same Git. This means that I cannot use rebase and merge. I have used vimdiff to sync changes between teamMates. However, this is time-consuming.

I have unsuccessfully tried to make the following directory structure where all branches are under one Git:

project
      | - I - myTeamMate1 - myTeamMate2

However, I run clone command for me and for my teammate:

git clone <url>

and I get the error message after running the second clone for my teammate

fatal: destination path 'dotFiles' already exists and is not an empty directory.

Which directory structure should I use with a team of 3 people, such that I can use rebase and merge commands?

解决方案

Just some other thoughts to complete Samuel's answer.

  • Unlike SVN, branches and directories are completely unrelated in Git: having 3 branches (one for each member of the team) does not mean 3 directories. That is not what you meant in your question (since your directories are actually 3 roots for 3 Git repositories), but I prefer mention it explicitly just in case ;)

  • Git being DVCS, the 3 repositories can be anywhere (not in 3 directories on the same computer). If they are reachable through an UNC path (\\desktop\path\to\repo), they can be designated as remote.

  • Git clone does allow you to get references to remotes branches, but does not create tracking local branches allowing you to get the work of your colleagues. The ruby module "remote branches" can help.

  • Be wary of rebase as it rewrites the SHA-1 of your branch (since you replay your commits on top of another branch): if your teammates based their merges on your branches, they will have to merge all your commits every time, even those already merged!
    It is best to have 2 branches in this case:

    • a working branch you are using for your development and rebase (to integrate the works of your peers, although even that operation could be done in its own branch)
    • a publishing public branch, on which you only merge your stable work, and which can then be used by other remote repositories as a source for merges.

这篇关于无法理解Git分支,合并和重新绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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