Today I downloaded a branch from the remote repository, and when I went to see information about the branches, I realized that the track of the branch has not been created locally with the remote repository branch, and the information was displayed like this:
$ git branch -vv
master 58951259 [origin/master] commit1
develop 12345687 [origin/develop] commit2
features/feature-25 12345678 commit3
The branch track has not been created. I wanted to have the tracking done (I thought it was done only by default), since later on you can see the commits ahead and behind the remote branch.
If you have a local branch and want to track the branch, use the command:
Example:
When you check out a branch from the remote it should do the tracking itself but to make sure we can add the --track option when checking out the branch:
When you create a local branch and want to push it to the remote and have the branch tracked, we can do the git push with the -u option (shortcut of --set-upstream). The track is uploaded and created.