The book "Pro git" mentions the concept of upstream branches when introducing branches.
Checking out a local branch from a remote tracking branch will automatically create a branch called a "tracking branch" (sometimes also called an "upstream branch")
From here, we can see that the upstream branch mentioned here refers to a local branch checked out from a remote branch.
However, when the "upstream shortcut" is mentioned later in this book, this upstream branch does not refer to the local branch:
if you likeAfter setting up the tracking branch, you can reference it through the @{upstream} or @{u} shortcut. So when you're on the master branch and it's tracking origin/master, you can use git merge @{u} instead of git merge origin/master
When we use git and push to a remote warehouse, we often encounter the concept of upstream branches. For example, when you push to the remote for the first time, you do not add any parameters:
git push
Then git will immediately prompt you to set up the upstream branch:
fatal: The current branch master has no corresponding upstream branch.
To push the current branch and establish tracking with the remote upstream, use
git push --set-upstream origin master
The upstream branch here seems to also refer to the remote branch.
So the question arises, what exactly is called an "upstream branch"? The book "Pro git" does not give an accurate concept; and it is also said on the Internet that the upstream branch is only a relative concept.
仅有的幸福2017-06-26 10:51:32
Simply speaking, upstream is the remote branch corresponding to your local branch. If you do not specify the remote branch when pushing pull or fetch, the upstream branch will be used.
typecho2017-06-26 10:51:32
Hello, first of all, I have not read any Git books, but I dare say that I am very proficient in Git operations, which I have learned through long-term practice. Maybe I can understand your confusion!
First of all, the brain cannot stay on the previous SVN, which is the concept of a central warehouse! First of all, there is no central repository in Git, so the question arises, which part of your local code should be submitted to the remote one? git branch --set-upstream branch
This branch is the remote branch. Set an existing branch to track the remote branch. After you set up the remote tracking branch, you can type the command normally and simply: git pull; git psuh;
For example, when you push the remote for the first time, you did not add any parameters:
git push
Then git You will be prompted immediately to set up the upstream branch:
Then you need to git push origin master; by default, the current remote branch is the main branch
代言2017-06-26 10:51:32
According to the usual usage, the upstream branch refers to a branch of the remote library. This library can be an account in github, or it can be a directory on a certain server (including local). set-upstream is to The current branch is connected to branches in other libraries, so that a set of code can be modified together instead of just doing it yourself