繁体   English   中英

将git用于两个分支

[英]Use git for two branch

认为我将在Master Branch中使用这三个文件

主:

index.php

  <b>hello</b>

test.php
img.jpeg

现在我从师父创建一个分支

NewBranch:

index.php

     <b>hello</b>

test.php
img.jpeg

现在我将编辑Master index.php文件,并将两行代码添加到master分支

主:

index.php

  <b>hello</b>
  <a>test</a>
  <p>good</p>     

我将在NewBranch中更改一些代码

NewBranch:

index.php

     <b>hello</b>
     <div>this is new branch line</div> 

我想更新NewBranch,所以我将在New Branch上有自己的编辑行,并且在Master Branch上也有更新的行

NewBranch :(应如下所示)

index.php

     <b>hello</b>
     <div>this is new branch line</div>
     <a>test</a>
     <p>good</p>  

我该如何实现? 我使用过netbeans Pull and Fetch,但没有用。 我也不想使用git子模块(因为我没有单独的文件夹)

  1. 您在两个分支上的更改都应该“提交”。 仅改变将无济于事。
  2. 然后您可以通过master重新设置NewBranch的基础( git rebase master NewBranch
  3. 现在,您的新分支具有自身和主分支的更改。 但是主人只会有它的改变。

有关rebase的更多详细信息,请参阅

这些是步骤(假设您正在使用gitBash):

git checkout newbranch

为newbranch进行更改git commit -a -m“您的消息”

git checkout master

为主人做改变

git commit -a -m "Your message"

现在正在合并

git checkout newbranch
git merge master
git push
git checkout master
git merge newbranch
git push
gitk //you should see that both are at the same level in the git tree

暂无
暂无

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

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