What is a git upstream

后端 未结 2 1915
青春惊慌失措
青春惊慌失措 2021-02-01 19:48

When you have created a github-repo and added the the github-repo as remote

git remote add origin https://github.com/githubname/reponame.git

t

2条回答
  •  说谎
    说谎 (楼主)
    2021-02-01 20:35

    In the command

    git push -u origin master
    

    The -u flag means that your local branch will become a tracking branch. That is, a branch that tracks a remote branch (the "upstream" branch), so that future git pull will know which branch to merge from and git push will be directed to the correct remote branch.

    origin is the remote repository you are pushing to.

    master is the refspec parameter. The refspec parameter specifies which local branch is pushed to what remote branch. It can be complicated, but in this case the short form master means to push the local master branch to the remote branch with the same name, origin/master.

    Technically, the tracking adds the following information about the master branch to your .git/config:

    [branch "master"]
        remote = origin
        merge = refs/heads/master
    

    and it creates a file here .git/refs/remotes/origin/master, representing the remote branch.

提交回复
热议问题