Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push new branch to remote repository with tracking option [duplicate]

Tags:

git

I am working on a local branch (feature1) created from mainline branch. I would like to push this local branch to remote repository. How to achieve this in git along with tracking option.

like image 735
Sunil Avatar asked Sep 13 '16 05:09

Sunil


People also ask

How do I push a new local branch to a remote git repository and track it too?

Push a new Git branch to a remote repoClone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.

How do you track a remote branch such that you have a copy of it locally?

You can tell Git to track the newly created remote branch simply by using the -u flag with "git push".

How do I push changes to my remote repository?

To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.


1 Answers

Push with the -u option:

git push -u origin <branch>

-u, short for --set-upstream, that is set the upstream in origin to the <branch> name. If you omit the branch name, the local branch name is used instead. Full story on Git's documentation.

like image 105
Dave Grabowski Avatar answered Sep 20 '22 15:09

Dave Grabowski