What is a git upstream

后端 未结 2 1917
青春惊慌失措
青春惊慌失措 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:23

    "Upstream" is the repo you cloned (some of) the branches in yours from, and where you push changes to those branches (and optionally entire new branches) once they've been committed. GitHub acts as your upstream because they store the revisions for you, in a centralized location.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题