开发者

How to merge codeline with git

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开发者_如何学JAVA 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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜