git 常用指令

62 阅读1分钟

常用指令自用留档

// 删除本地分支
git branch -d localBranchName

// 删除远程分支
git push origin --delete remoteBranchName

// To see local branches**, run this command:
git branch

// To see remote branches**, run this command:
git branch -r

// To see all local and remote branches**, run this command:
git branch -a

// rename branch name
1.  Rename your local branch:

    -   If you are on the branch you want to rename:  
        `git branch -m new-name`
    -   If you are on a different branch:  
        `git branch -m old-name new-name`

1.  Delete the `old-name` remote branch and push the `new-name` local branch:  
    `git push origin :old-name new-name`

1.  Reset the upstream branch for the new-name local branch:  
    Switch to the branch and then:  
    `git push origin -u new-name`