AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Git set upstream local branch11/19/2023 # 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 We can also set the default remote branch by using the git branch command. Consider the below output: In the given output, everything is up to date with the remote branch. Please note that defining an upstream for a local branch might fail if the remote you want to set upstream to has not already been fetched locally. To better understand the origin master click here. The former option was deprecated in favor of the latter in git v1.8.0. If you havent deciphered it yet, gsut stands for Git Set Upstream. This information helps tremendously in staying up-to-date. The above command will set the master branch as the default remote branch. gsut to set the upstream tracking branch to the branch named name.It would be nice if there was an option to setting the upstream to origin as per above, however. (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. It can also be done by pushing a commit for the 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. Git can now also tell you about unsynced commits which you haven't pushed or pulled, yet. 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". This relationship is very helpful for two reasons: Let's also say that you've set the remote "origin/development" as its upstream branch. Let's say that your current local HEAD branch is named "development". git pull If you wish to set tracking information for this branch you can do so with: git branch -set-upstream-toorigin/ mybranch Doing git branch -set-upstream-toorigin/mybranch mybranch solved the problem.Why should you set up an upstream branch for a local branch? Please specify which branch you want to merge with. In practice, however, in makes lots of sense to see them as counterparts - connected in a so-called "tracking connection". When you try to checkout a branch, you pull this. In theory, local and remote branches in Git are completely separate items. An upstream branch is a remote branch that is hosted in a remote repository, such as GitHub or Bitbucket.
0 Comments
Read More
Leave a Reply. |