git 常用指令

143 阅读1分钟
  • 删除本地git分支
    git branch -d 分支名  
    #注意:当前分支不能处于你需要删除的分支 
    #如果删除不了可以强制删除,git branch -D 分支名
    
  • 删除远程分支
    git push origin --delete 分支名
    
  • 重命名本地并同步到远程分支
    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