Git

Git Usage

Posted by cya on March 26, 2022

Rename local branch and remote branch

  1. Switch to the local branch to be renamed

    1
    
    git checkout <old-name>
    
  2. Rename local branch

    1
    
    git branch -m <new-name>
    
  3. Push <new-name> branch to remote repository

    1
    
    git push origin <new-name>
    
  4. Delete <old-name> branch in remote repository

    1
    
    git push origin --delete <old-name>
    

View the relationship between local branch and remote branch

1
git branch -vv

Create connection between local branch and remote branch

Checkout to the target local branch.

1
git push -u origin <remote-br>

or

1
git branch --set-upstream-to=origin/<remote-br> <local-br>

After this operation, you can run git push and git pull in the branch and it will automatically communicate with origin/<remote-br>.