git branch management push local branches to remote branches, etc.

1. Create a local branch local_branch

     git branch local_branch

 

2. Create a local branch local_branch and switch to the local_branch branch

   git checkout -b local_branch

 

3. Switch to branch local_branch

    git checkout local_branch

 

4. Push the local branch local_branch to the remote branch remote_branch and establish an association relationship

      a. The remote has a remote_branch branch and has been associated with the local branch local_branch and the local has been switched to local_branch

          git push

     b. The remote has a remote_branch branch but is not associated with the local branch local_branch and the local has been switched to local_branch

         git push -u origin/remote_branch

     c. There is no remote_branch branch on the remote, and the local has been switched to local_branch

        git push origin local_branch:remote_branch

5. Delete the local branch local_branch

      git branch -d local_branch

6. Delete the remote branch remote_branch

     git push origin  :remote_branch

     git branch -m | -M oldbranch newbranch Rename the branch. If the newbranch name branch already exists, you need to use -M to force the rename, otherwise, use -m to rename.

   git branch -d | -D branchname delete branchname branch

   git branch -d -r branchname delete remote branchname branch

 

7. View local branches

      git branch

 

8. View remote and local branches

      git branch -a

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325019729&siteId=291194637