Getting existing git branches to track remote branches

Use the set-upstream arg:

git branch --set-upstream local-branch-name origin/remote-branch-name

Running the above command updates your .git/config file correctly and even verifies with this output:

“Branch local-branch-name set up to track remote branch remote-branch-name from origin.”

EDIT: As martijn said: “In version Git v1.8.0, –set-upstream is deprecated. Use –set-upstream-to instead.”

git branch --set-upstream-to local-branch-name origin/remote-branch-name

See this for more information.

Leave a Comment