git合併遠端分支到本地分支的兩種方式

2021-09-06 21:20:39 字數 2554 閱讀 4669

在使用版本號工具提交改動之前,都須要通過update先將本地**更新到最新版本號。svn通過svn update就能夠實現,那麼git怎樣實現呢?

[

root@~

/wade

/nodejs

/express-routing

]#git fetch [email protected]:billfeller/express-routing.git master

from github.com:billfeller

/express-routing *

branch master -

>

fetch_head

[root@~

/wade

/nodejs

/express-routing

]#git log

commit c7f2ae18cd3648d32fa3dcd50060fa7f13a093b1

author: billfeller

<

billfeller

@gmail.com

>

date: fri nov

2101:41:

402014

+0800

express-routing

test

commit dd5923229abe4e1da706ce53ad4b41154cb89ea7

author: billfeller

<

billfeller

@gmail.com

>

date: fri nov

2101:07:03

2014

+0800

merge branch

'master'

, remote branch

'origin'

commit d1aee713ca98e5cdead1978dcfcf7a55974a2851

author: billfeller

<

billfeller

@users.noreply.github.com

>

date: fri nov

2101:05:

122014

+0800

create readme.md

commit 5aa66ffc06b95aeb8ef42627fe4b97c95cb660b9

author: billfeller

<

billfeller

@users.noreply.github.com

>

date: fri nov

2101:03:05

2014

+0800

initial commit

[root@~

/wade

/nodejs

/express-routing

]#git merge origin/master

updating c7f2ae1..8d3058b

fast-forward

readme.md |2

++ 1files changed,

2insertions(+

), 0deletions(-

)

2. 通過git pull一步到位,相當於是從遠端獲取最新版本號並merge到本地,即第一種方法的快捷命令。

[

root@~

/wade

/nodejs

/express-routing]#

git pull

remote: counting objects:

3, done.

remote: compressing objects:

100%(2

/2), done.

remote: total 3(

delta 1)

, reused 0(

delta 0)

unpacking objects:

100%(3

/3), done.

from github.com:billfeller

/express-routing

8d3058b..82a02eb master -

>

origin

/master

updating 8d3058b..82a02eb

fast-forward

readme.md |2

+- 1files changed,

1insertions(+

), 1deletions(-

)

在實際開發中,還是推薦使用第一種方式,由於git fetch更安全一些,能夠通過git fetch後檢視更新情況,再決定是否進行合併。

git提交本地分支到遠端分支

1 遠端倉庫相關命令 檢出倉庫 git clone git 檢視遠端倉庫 git remote v 新增遠端倉庫 git remote add name url 刪除遠端倉庫 git remote rm name 修改遠端倉庫 git remote set url push name newurl ...

git推送本地分支到遠端分支

有時候我們開發需要開乙個分支,這樣可以有效的並行開發.開分支有兩種方式 git checkout b feature branch origin feature branch 檢出遠端的feature branch分支到本地 git checkout b feature branch 建立並切換到分...

git推送本地分支到遠端分支

有時候我們開發需要開乙個分支,這樣可以有效的並行開發.開分支有兩種方式 git checkout b feature branch origin feature branch 檢出遠端的feature branch分支到本地 git checkout b feature branch 建立並切換到分...