


# and have 2 and 3 different commits each, respectively. # Your branch and 'origin/development' have diverged, Git tells you about this right in the output for "git status": $ git status This information helps tremendously in staying up-to-date. (b) if there are 4 commits on the remote upstream branch which you haven't pulled yet, then your local branch is "4 commits behind" its upstream branch. (a) if you have 2 commits in your local repository which you haven't pushed to the remote yet, then your local branch is "2 commits ahead" of its upstream branch. For example, if you have checked out foo branch, your HEAD now is foo. The easiest way to set the upstream branch is to use the git push command with the -u option for upstream branch. git branch -set-upstream-to origin/foo Add Git Upstream Using Git HEAD In git, HEAD refers to the currently active branch. That’s itthat’s all it doesbut it has all those implications noted above. The -set-upstream-to sub-command takes the name of any existing branch, such as origin/solaris, and sets the current branch’s upstream to that other branch. It will enable tracking, and you will be able to pull the changes. To set it now, rather than during the first push, use git branch -set-upstream-to. Git can now also tell you about unsynced commits which you haven't pushed or pulled, yet. To avoid this, you can set git upstream using the following command. This method makes sense if you often change the flow of your current branch. With an upstream branch set, you can simply use the shorthand commands "git pull" and "git push" - instead of having to think about the exact parameters like in "git push origin development". There are two ways to set an upstream branch in Git: Using git push, which is the fastest method if you need to set a single upstream branch. This relationship is very helpful for two reasons: org :my-user/some-project. org :my-user/some-project.git (fetch) origin git bitbucket. upstream is the repository that we have cloned the project. In the code, the origin is your default remote repository name and ‘-u’ flag is upstream, which is equivalent to ‘-set-upstream. In fact, you can supply it on any later push, and it will set or change the upstream at that point. So you should supply -u on the first push. Let's also say that you've set the remote "origin/development" as its upstream branch. First, verify that you have already setup a remote for the upstream repository, and hopefully an origin too: git remote -v origin git bitbucket. git push -u origin master is used for pushing local content to GitHub. 3 If you run your first git push as git push -u origin solaris i.e., if you add the -u flagGit will set origin/solaris as the upstream for your current branch if (and only if) the push succeeds. Let's say that your current local HEAD branch is named "development". Why should you set up an upstream branch for a local branch? In practice, however, in makes lots of sense to see them as counterparts - connected in a so-called "tracking connection". Once all the changes for a feature is complete, this newly created branch can be merged with mainline development.In theory, local and remote branches in Git are completely separate items. This branch can hold, one or more commits.

To enable this, git offers the option to create a new branch.
git push -uIt is recommended to work with each feature or issue in isolation. The easiest way to set the upstream branch is to use the git push command with the -u option for upstream branch.

So, this is why you point to origin/master. But, setting the upstream is all about telling Git which local tracking branch to be used for git pull. Once the above command is executed, we notice that upstream is also tracked git remote -v origin (fetch) origin (push) upstream (fetch) upstream (push) Method 3 - Working with branches As used inside of git pull origin master, origin master refers to the true master branch living on the remote. So, to enable tracking on upstream execute the following command. Most commonly, developers would need to keep origin in sync with its parent upstream. git remote -v origin (fetch) origin (push) Cloning creates a local copy of the repository git clone īy default, the tracking will be only on the origin.
