Git管理多個遠端分支

2021-09-20 05:31:28 字數 837 閱讀 5517

首先git不能單獨設定pull和push的源,也就是說pull和push的只能保持一致!

背景:本人的部落格是基於hexo-theme-next的,但是因為個人喜好,基於原始碼做了一寫改動。可是官方原始碼更新了我也要跟著一起更新呀,於是使用git設定不同的源來保持和官方同步更新。

檢視本地源

> git remote -v

檢視遠端分支和本地分支的對應關係

> git branch -vv

* master 77e072b [origin/master] curl新增引數

新增源

> git clone 

> git remote add office

新增分支指向office/master 分支

# 檢出office/master分支到本地,並命名hexo-theme-next

> git checkout -b hexo-theme-next office/master

或者,先新建分支,然後設定upstream

> git branch hexo-theme-next

> git branch --set-upstream-to=office/master hexo-theme-next 或 git branch -u office/master hexo-theme-next

最後,基於自己的喜好修改檔案,再把修改後的內容提交到自己的倉庫

> git push origin hexo-theme-next

Git管理多個遠端分支

在此目錄下使用git要注意一下幾點 因為這個目錄是管理遠端多個不同的分支的專案,所以使用git之前確認一下幾點 開啟git bash,使用命令 git config list檢視目前本地的目錄檔案是和遠端的那個目錄位址關聯,確認好目錄,比方說 現在遠端分支是 github653224 gitproj...

git遠端分支管理

1.建立 remote mkdir my project.git git init bare 2.建立本地git cd my project git init 3.連線並提交 git add git commit m commit message git remote add origin ssh ...

Git遠端和分支管理

git是分布式版本控制系統,最重要的優點就是遠端倉庫託管 不用自己搭建乙個伺服器,在github上面註冊乙個賬戶就可免費獲取遠端倉庫。第一次推送的時候需要本地庫關聯遠端庫,使用命令git remote add origin git server name path repo name.git ori...