2014-10-17 77 views
0

想我會在主分支使用這三個文件使用git兩個分支

MASTER:

index.php 

    <b>hello</b> 

test.php 
img.jpeg 

現在我師父

NewBranch創建一個分支

index.php 

    <b>hello</b> 

test.php 
img.jpeg 

現在我將編輯主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所以我會對新科我自己編輯的線條,並更新線路上主科

NewBranch:(應該是這樣的,如下)

index.php 

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

我怎樣才能做到這一點?我使用了netbeans Pull和Fetch,但沒有奏效。我也不想使用git submodule(因爲我沒有單獨的文件夾)

+0

所以,你想合併你的主分支到你的新分支,同時保持主分支的原樣? – Grice 2014-10-17 13:43:26

+0

是的,我打算合併兩個分支,但是當我使用netbeans pull(合併)時,它顯示我>需要合併提交以使當前分支與orogon/master同步 是否要將當前分支與起源/主人還是將它重新映射到起源/主人? 合併重新取消 – Ata 2014-10-17 13:59:36

+0

當我點擊合併時,它不合並新行 – Ata 2014-10-17 13:59:58

回答

0
  1. 您在兩個分支上的更改都應該是「已提交」。只有改變纔會有好處。
  2. 然後你可以重新綁定你的NewBranch over master(git rebase master NewBranch
  3. 現在你新建的分支有自己和主人的變化。但是主人只會有變化。

有關rebase的更多詳細信息,請參閱this

+0

(雖然我預計合併對於我的工作已經足夠了),但我將無法提交我的NewBranch Any More。 – Ata 2014-10-17 14:02:33

0

這些步驟(假設您正在使用gitBash):

git checkout newbranch 

做newbranch git的變化提交-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