git修改本地和遠程分支的名字

git修改本地和遠程分支的名字

  • 有時候,分支名字寫錯了,要改。
  • 那需要本地修改分支名字,刪除遠程的, 然後本地新分支推動到遠程,同時跟蹤到遠程新的分支
  • 具體過程是:

流程

1 sourcetree 修改分支名字,實際上是修改本地的

右鍵修改分支名字:

  • 在這裏插入圖片描述

命令行:

//本地分支改名字
git branch -m old_branch new_branch # Rename branch locally

2 然後查看本地,發現分支名字已經修改了

3 刪除遠程分支

 git push origin :老分支名字_2.0.2.2_fb

4 本地新分支跟蹤到遠程新分支

  • 可以看到,執行之後,遠程分支的名字纔會修改。
git push --set-upstream origin  新分支名字

-在這裏插入圖片描述

參考git 修改本地和遠程分支名稱

git branch -a #查看所有分支
git branch -r #查看遠程分支
git branch -vv #查看本地分支所關聯的遠程分支
//本地分支改名字
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 或者git push -u origin new_branch# Push the new branch, set local branch to track the new remote

注意:把origin改爲自己的名稱

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章