1. View remote branches

Use the following git command to view all remote branches:

git branch -r

View all remote and local branches: git branch -a

Git branch In the output, the current branch is preceded by an *.

Git branch-vv Displays the relationship between the current branch and remote branches

Pull the remote branch and create the local branch

Methods a

Use the following command:

Git checkout -b "origin" /" origin"

Git checkout-b master-panyu origin/master-panyu

This mode creates a local branch x and automatically switches to the local branch X.

Local branches created in this way map to remote branches.

Way 2

Use the following command:

Git fetch Origin Remote branch name x: local branch name x

Using this method will create a new branch x locally, but will not automatically switch to the local branch X, requiring manual checkout.

The local branch created in this way does not map to the remote branch.

3. The function of establishing the mapping between local and remote branches

Establish a mapping between local and remote branches (or track).

With Git pull or Git push, you don’t have to specify which remote branch to pull merge from and which remote branch to push to. git branch -vv

The local and remote branches above have mappings, if not, you need to manually set up: Git branch -u origin/ git branch name/git branch — set-upgrade-to origin/ Git branch name origin is the git address flag. You can establish a mapping between the current branch and remote branches.

Cancels the mapping between the local and remote branches

Git branch –unset-upstream: You can use git branch-vv again to see the mapping between local and remote branches

Question to consider: Can local branches only track remote branches with the same name?

Git branch-vv: git branch -vv: git branch -vv: git branch -vv: git branch -vv: git branch -vv: git branch -vv