git fetch 更新遠端倉庫到本地

2021-07-26 18:52:56 字數 2373 閱讀 5724

方式一1. 檢視遠端倉庫

從上面的結果可以看出,遠端倉庫有兩個,乙個是eoecn,乙個是origin

2 ,從遠端獲取最新版本到本地

我的本地參考**和遠端**相同,所以是already up-to-date

以上的方式有點不好理解,大家可以使用下面的方式,並且很安全

方式二1.檢視遠端分支,和上面的第一步相同

2. 從遠端獲取最新版本到本地

比較本地的倉庫和遠端參考的區別

1

2

$

gitdiff

temp

su@suchangli/e

/eoe_client

/android-(

master

)

命令的意思是:比較master分支和temp分支的不同

由於我的沒有區別就沒有顯示其他資訊

4. 合併temp分支到master分支

1

23

$

gitmerge

temp

alreadyup-

to-date.su

@suchangli/e

/eoe_client

/android-(

master

)

由於沒有區別,所以顯示already up-to-date.

合併的時候可能會出現衝突,有時間了再把如何處理衝突寫一篇部落格補充上。

5.如果不想要temp分支了,可以刪除此分支

1

23

$

gitbranch-d

temp

deleted

branch

temp

(was

d6d48cc

).su

@suchangli/e

/eoe_client

/android-(

master

)

如果該分支沒有合併到主分支會報錯,可以用以下命令強制刪除git branch -d 《分支名》

總結:方式二更好理解,更安全,對於pull也可以更新**到本地,相當於fetch+merge,多人寫作的話不夠安全。

如有錯誤請指正

Git push 到遠端倉庫

首先git繫結username password email git config user.name git config user.password git config user.email git config global user.name username git config glo...

git fetch 遠端分支

打算把github上的乙個分支取到本地,直接輸入命令 git checkout origin a 結果出錯 error pathspec origin feature renrendai tongji did not match any file s known to git.看到有了如下方法 先執...

git 提交專案到遠端倉庫及更新提交功能

首先在git伺服器上面新建乙個倉庫 在本地新建乙個倉庫名 並通過git bash 命令列工具進入到該目錄 執行以下命令 git init git remote add origin yourgithubaddress yourgithubaddress 替換成你遠端倉庫的位址 和遠端倉庫專案進行關聯...