Git Branching Check out a new branch tracking a remote branch

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

There are three ways of creating a new branch feature which tracks the remote branch origin/feature:

  • git checkout --track -b feature origin/feature,
  • git checkout -t origin/feature,
  • git checkout feature - assuming that there is no local feature branch and there is only one remote with the feature branch.

To set upstream to track the remote branch - type:

  • git branch --set-upstream-to=<remote>/<branch> <branch>
  • git branch -u <remote>/<branch> <branch>

where:

  • <remote> can be: origin, develop or the one created by user,
  • <branch> is user's branch to track on remote.

To verify which remote branches your local branches are tracking:

  • git branch -vv


Got any Git Question?