

In many cases, "origin" is a remote repo shared by your team, like a repository on GitHub. Here we're pushing the "master" branch of our local repository to the remote labeled "origin". So, a common use of this command looks like this: $ git push -u origin master Nevertheless, a more common way is to take advantage of remote-tracking.
#GIT ADD REMOTE TRACK BRANCH FULL#
You can get a full list of remote references explicitly with git ls-remoteThis is useful since adding this tracking reference, among other benefits, makes the specified remote branch become the default for commands like git pull or git rebase when no other arguments are given. Remote references are references (pointers) in your remote repositories, including branches, tags, and so on. This option is an alias for -set-upstream, which will add an upstream tracking reference for the branch you're pushing. One important thing to point out is the -u option. Pushing the branch to the remote repository and tracking the upstream branch can be done in one command: $ git push -u Īs you probably guessed, the branch is pushed to in this case.

Now that you have a new branch for your feature, you make some changes and additions to your code, commit it, and are ready to share it with the rest of your team. But this is almost as tedious as the previous commands. And if I enter git branch -set-upstream-toorigin/mybranch mybranch, then it works.
In this short article that's exactly what I'll go over.įor now let's assume that you've created a new branch in your repository, possibly to implement a new feature or fix a bug: $ git checkout -b Your local repo will now have a read only copy of the remote tracking branch. See git-pull (1) for details git pullOr maybe if you're like me, you might just be paranoid and want to store everything in a remote repository, like GitHub, for safe-keeping in case you do something stupid on your local machine.Įither way, there are many ways to do so, one of which would be to push a local branch to a remote repo. Whether you've been programming for decades or just started out, at some point in your career you'll need to share your changes to a codebase.
