Git Fetch fails to work on bare repo, but git pull works on normal repo

后端 未结 1 1702
礼貌的吻别
礼貌的吻别 2021-02-05 22:44

First, the big picture: I\'m trying to write a git post-receive script for a Redmine / Gitolite server I\'m running. As per various recommendations, I\'m creating a bare and loc

相关标签:
1条回答
  • 2021-02-05 23:46

    Your fetch hasn't updated the master branch, only FETCH_HEAD (see "What does FETCH_HEAD in Git mean?").

    As mentioned in "how do I pull to a bare repository?", you should do a:

    git fetch origin master:master
    

    Or, for all the branches:

    git fetch origin +refs/heads/*:refs/heads/*
    

    Colin D Bennett added:

    If you want to fetch these on a regular basis, you should consider:

    git config remote.origin.fetch +refs/heads/*:refs/heads/*
    

    which will allow you to type git fetch to sync your branches with the remote.
    Note that this make sense only in a bare repository where local branches are not supposed to be edited.

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