Push a new local branch to a remote Git repository and track it too – Stack Overflow
Posted by jpluimers on 2016/07/27
Just what I needed: Push a new local branch to a remote Git repository and track it too – Stack Overflow But watch the comments to this answer:
Answer:
In recent versions of Git (1.7.0 and later), you can checkout a new branch:
git checkout -b <branch>Edit files, add and commit. Then push with the
-uoption:git push -u origin <branch>Git will set up the tracking information during the push.
Comments:
–jeroen






git push -uwas introduced in Git 1.7.0 (2010-02-12). – Chris Johnsen Jun 4 ’11 at 4:16-uis short for--set-upstream—for what it does and why it’s needed I wouldn’t mind some explanation, too. :) – Anton Strogonoff Mar 9 ’14 at 6:07push.defaultis set toupstream, this will not do what you think it will do. It will try to push over the existing tracking branch. Use:git push -u origin mynewfeature:mynewfeatureor dogit branch --unset-upstreamfirst. – void.pointer May 19 ’14 at 18:07