![]() This same command can be used for any branch. When a repo is cloned, it has a default remote called. In many cases, "origin" is a remote repo shared by your team, like a repository on GitHub. Git upstream generally refers to the original repo that you have forked from other git repositories. 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 ![]() This 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. 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. (b) if, on the other hand, there are 4 commits on the remote branch that you havent downloaded yet, then your local branch is '4 commits behind' its remote counterpart branch. 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. (a) if you have 2 commits only locally that you havent pushed to the remote yet, your local branch is '2 commits ahead' of its remote counterpart branch. 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. 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 A few commands, like git branch -vv, will show the upstream setting but mark it as gone. Or 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |