使用git表示两个分支


Use git for two branch

我想在主分支中使用这三个文件

主:

index.php
  <b>hello</b>
test.php
img.jpeg

现在我从主创建一个分支

新建分支机构:

index.php
     <b>hello</b>
test.php
img.jpeg

现在我将编辑Masterindex.php文件,并将向主分支添加两行代码

主:

index.php
  <b>hello</b>
  <a>test</a>
  <p>good</p>     

我会在NewBranch 中更改一些代码

新建分支机构:

index.php
     <b>hello</b>
     <div>this is new branch line</div> 

我想更新NewBranch,这样我就可以在NewBranch上编辑我自己的行,也可以在MasterBranch上更新行

NewBranch:(应该如下)

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

我怎样才能做到这一点?我使用过netbeans Pull和Fetch,但没有起作用。我也不想使用git子模块(因为我没有单独的文件夹)

  1. 两个分支上的更改都应该"提交"。只有改变是没有好处的
  2. 然后,您可以将NewBranch的基础重新设置为master(git rebase master NewBranch
  3. 现在,你的新分支本身和master都发生了变化。但大师只有它的变化

有关重新基准的更多详细信息,请参阅。

以下是步骤(假设您使用的是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