基於git學習更改本地和遠端分支的名稱

2021-09-30 01:12:59 字數 771 閱讀 2286

git branch -m old_branch new_branch # rename branch locally 

git push origin :old_branch # delete the old branch

git push --set-upstream origin new_branch # push the new branch, set local branch to track the new remote

原分支名稱為oldname

新分支名稱為newname

1. 本地分支重新命名(未推送到遠端)

git branch -m oldname newname

2. 遠端分支重新命名 (已經推送遠端-且本地分支和遠端分支名稱相同)

a. 重新命名遠端分支對應的本地分支

git branch -m oldname newname

b. 刪除遠端分支

git push --delete origin oldname

c. 上傳新命名的本地分支

git push origin newname

d.把修改後的本地分支與遠端分支關聯

git branch --set-upstream-to origin/newname

git刪除遠端分支和本地分支以及更改本地和分支名字

問題描述 當我們集體進行專案時,將自定義分支push到主分支master之後,如何刪除遠端的自定義分支呢 問題解決 1 使用命令git branch a 檢視所有分支 注 其中,remote origin master表示的是遠端分支 2 刪除遠端分支 注 如上所示,使用命令 git push or...

本地Git遠端連線Github並更改檔案

遠端連線github 在要上傳檔案的目錄中新建本地倉庫 在git bash中輸入git initgit會自動在該目錄下建立乙個.git檔案,該檔案即為本地倉庫 如果不是必要請不要刪除該檔案 新增遠端倉庫 git remote add origin將要上傳的檔案新增到git的暫存區 git add將更...

基於本地檔案或者本地Git倉庫建立遠端Git倉庫

1,在本地機器上 建立本地git倉庫 cd extend1 data www kb new git init git add git commit m my initial commit message 2,在遠端伺服器上 建立空的遠端git倉庫 sudo su git cd repositorie...