How to switch branches, pull branches, merge branches in git

There are three types of branches in git:

  1. local branch

    The local branch is the branch we usually operate. The default in git is the master branch

    Create a branch: git branch b1

    Switch branches: git checkout b1

  2. remote branch

    It actually points to a branch on the remote server and is used to track changes in the remote branch

  3. tracking branch  

    A tracking branch is a local branch that has a direct connection with a remote branch (local bookmarks, aliases of the remote branch), and a tracking branch is a local branch

     

  4. When we use the git pull command on the tracking branch, it will automatically fetch from the corresponding remote branch, and then merge to the branch. If we want to use the git push command directly on the tracking branch, let it automatically push to the corresponding remote On branch, when we use the git clone command, a master branch will be automatically created locally to track origin/master.

Guess you like

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