簡體   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