代码之家  ›  专栏  ›  技术社区  ›  Juan Dela Cruz

如何在GIT中基于两个分支创建特征分支?

  •  1
  • Juan Dela Cruz  · 技术社区  · 7 年前

    我有一个问题,基本上我想创建一个功能分支。我所做的是从master创建一个名为TEST\u RUN的功能分支(假设master是Q1),然后这将使FB TEST\u运行与master完全相同,对吗?

    但我希望TEST\u RUN中的一些文件夹基于Q2,因为master仍然是Q1,所以Q2还没有上线。

    这可能吗?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Mamun Kayum    7 年前

    试试这个,如果我理解这个问题,那么这就是你想要的:

    on branch-Master(Q1): has a, b, c
    
    from branch Master(Q1) -> checkout/switch to Feature branch(F) 
    > git checkout -b F
    From Feature branch(F): git merge `Q2`
    > git merge Q2  
    

    如果不起作用,请让我进一步知道。

    编辑:

    If you want only a file from Q2:
    git checkout Q2 file1
    
    If you want entire folder from Q2: 
    git checkout Q2 -- c
    
    Note: c is the folder from Q2,  c could be a directory path as well, like :
      folder1/c
    
    But its not a git merge.