I sometimes use the checkout -b
option to create a new branch, check it out at the same time and set up tracking in one command.
In a new environment, I
You could follow these steps when you stumble upon this issue:
git remote show origin
which outputs this:
remote origin Fetch URL:
Push URL: HEAD branch: development Remote branches: development tracked Feature2 tracked master tracked refs/remotes/origin/Feature1 stale (use 'git remote prune' to remove) Local branches configured for 'git pull': Feature2 merges with remote Feature2 development merges with remote development master merges with remote master Local refs configured for 'git push': Feature2 pushes to Feature2 (up to date) development pushes to development (up to date) master pushes to master (local out of date)
» git remote update Fetching origin From gitlab.domain.local:ProjectGroupName/ProjectName * [new branch] Feature3 -> Feature3
As you can see the new branch has been fetched from remote.
3. Finally, checkout the branch with this command
» git checkout -b Feature3 origin/Feature3 Branch Feature3 set up to track remote branch Feature3 from origin. Switched to a new branch 'Feature3'
It is not necessary to explicitly tell Git to track(using --track) the branch with remote.
The above command will set the local branch to track the remote branch from origin.