1.切換到需要基於變更的主分支
git checkout master
2.創建本地新分支並切換至新分支
git checkout -b new_branch
3.將新建分支推送至遠程倉庫
git push origin new_branch:new_branch
4.解決報錯:當前分支沒有跟蹤信息。(There is no tracking information for the current branch.)
git branch --set-upstream-to=origin/new_branch
5.刪除本地舊的分支,同時刪除遠程舊的分支
# 刪除遠程分支: git push origin --delete 分支名字 # 刪除本地分支: git branch -D 分支名字