如何合并codeline与git [英] How to merge codeline with git
问题描述
我有一个改编号为A的代码行,我在其上编辑了一些文件,然后添加 p4打开$ 通过
添加到我的本地存储库中。 b git add
,然后将
还有另外一个工作在SAME代码行上的变化编号为B的人。他还编辑了一些文件,其中一些是我们之间的通用文件,他也做了 git init
, git add
和 git commit
到他的本地存储库。
首先我们没有中央全球回购协议。但是现在我想将他的git更改合并到我的客户端中。这怎么能通过git完成?
myGitCodeLine ------?
hisGitCodeline ------ /
然后你需要克隆他的回购(B)以获得所有的变化。
您可以在自己的仓库中创建一个分支A,并通过第二个仓库B添加所有检出的项目。
这样做的一个诀窍是:
- 在您的仓库中创建第二个根分支(以便从空白内容开始)
git checkout - 孤儿branchForB
:参见这个SO回答作为示例。使用- work-tree =< path>
选项来添加文件其他目录:
git --work-tree = / path / to / file add。
,如
完成后:
I have a codeline with certain change number A. I git init
on it and I edit some files and then add p4 opened
files by git add
and then git commit
to my local repository.
There's another guy working on the SAME codeline with different change number B. He also edited some files, some of which are common files between us and he also did the git init
, git add
and git commit
to his local repository.
We don't have a central global repo in the first place. But now I want to merge his git changes into my client. How can this be done via git?
myGitCodeLine------?
hisGitCodeline------/
First you need some kind of access to his repo. A simple shared directory is enough. Other options are detailed here.
Then you need to clone his repo (B) in order to get all the changes.
You can make a branch in your own repo A, and git add everything checked out by the second repo B.
A trick to do that easily is to:
- make a second root branch in your repo (in order to start from an empty content)
git checkout --orphan branchForB
: see this SO answer as an example. - use
--work-tree=<path>
option to git to add files from other directory:
git --work-tree=/path/to/file add .
, as mentioned in "How can I create a new branch in git from an existing file tree?"
Once that is done:
- you can merge that second branch into your main branch.
- you need to ask B to clone your repo A in order for you both to work from a common history.
这篇关于如何合并codeline与git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!