gitolite: default remotes for new repository

后端 未结 2 1800
星月不相逢
星月不相逢 2020-12-06 10:20

I\'ve installed gitolite (locally for now, to experiment) and it seems to work, except that new repositories are not tracking the remote by default after a git clone. If I r

相关标签:
2条回答
  • 2020-12-06 11:03

    You can use git branch --set-upstream command, eg.:
    git branch --set-upstream develop origin/develop

    0 讨论(0)
  • 2020-12-06 11:15

    The first git push always require to specify the branch you want to push.

    git push -u origin master
    

    Then the next push can be done, from the same branch, as you intended:

    git push
    

    From git push man page:

    The special refspec : (or +: to allow non-fast-forward updates) directs git to push "matching" branches: for every branch that exists on the local side, the remote side is updated if a branch of the same name already exists on the remote side.
    This is the default operation mode if no explicit refspec is found.

    Since you have cloned an empty repository, the first push doesn't find any matching branch (there is none on the upstream repo 'origin')

    Note: See "What is the result of git push origin?":

    The default policy for git push will change with git 2.0 (or maybe git1.9)

    A new mode for push, "simple", which is a cross between "current" and "upstream", has been introduced.
    "git push" without any refspec will push the current branch out to the same name at the remote repository only when it is set to track the branch with the same name over there.
    The plan is to make this mode the new default value when push.default is not configured.

    So in the git push -u origin master, the -u (--set-upstream-to) is important here (not just to push the branch with the same name to the remote 'origin', but it a remote tracking branch.

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