Git: Difficulty Getting Existing Git Repository to Track New Bare Remote RepositoryįYI: all commands tested with git V2.32 on Windows.Only if the upstream repository has been given a name using git remote add Īnd git push -set-upstream has been used with this name, the full power of remote tracking branches is available in all git commands. Git push does not create a reference to the remote branch head in. If is given as an URL or file path, see for example this example: git push -set-upstream master Why do I have to “git push -set-upstream origin ”?.That is, when these config variables are set, you can just issue git push and git will know (using these variables) the remote repository and upstream branch to use. The magic happens when these config variables are used by, e.g., git fetch, git pull or git push to figure out the upstream repository and remote branch for a local branch if you don't explicitly specify them on the commandline. This will output any variables that start with "branch." You can query whether any of these config variables are set using git config -get-regexp ^branch\. Based on the way how this upstream information is stored, a local branch can have no more than a single set of upstream information. If your local branch is called main, the respective config variables are and. Upstream information is stored under the local branch name. It stores upstream information (i.e., remote repository and branch) for the local branch in config variables. In addition to the operation that a git push without the option -set-upstream does, this option makes git push set at least two configuration variables: Finally, I assume a common git configuration. For simplifying the answer, I further specified that the local branch that you are on has the same name as the remote branch on your upstream repository that you are pushing to. As you see, I assumed that the git command in question is git push.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |