git-svn fetch isn't pulling in the latest versions

后端 未结 4 842
北荒
北荒 2020-12-17 09:07

When I execute a

git svn fetch

from my repository, it returns nothing and doesn\'t update even though there are new commits under svn.

相关标签:
4条回答
  • 2020-12-17 09:39

    git svn fetch only copies new revisions to your local object database, very much like git fetch – both only synchronize object databases. It will not update your branch and working copy. To get the newly fetched changes into your branch, use git svn rebase; it will re-apply all your local changes on top of the latest svn revision.

    git svn rebase will do a fast-forward when there are no local commits, so it should not mess with history. Alternatively you could use git merge --ff-only git-svn to fast-forward to the most recent svn revision (and abort when it is not fast-forwardable, i.e. not a direct descendant)

    You should only use git svn reset when upstream svn has changed history (svndump/svnadmin) and you need to re-fetch the new commits, but this should almost never happen (otherwise blame the admin!)

    0 讨论(0)
  • 2020-12-17 09:45

    I found the answer, the svn data is loaded in to an inactive thread that would normally be merged in to the active branch, which doesn't exist in a bare repository. I tried to do a reset, but that needs an active branch too. The final answer was:

    git reset --soft refs/remotes/git-svn
    
    0 讨论(0)
  • 2020-12-17 09:49

    Has the same issue here in 2018 with the latest git. Resolved by removing the .rev_map and index files and rerun git svn fetch.

    /.git/svn/refs/remotes/origin/trunk/.rev_map.<GUID>
    /.git/svn/refs/remotes/origin/trunk/index
    

    Somehow it has been stuck on incorrect last svn revision association in the cache. In mine case it was the r32 revision which actually was the r31 revision (because r32 and r31 has clearly different commit messages, this is how i detected that) and it has been showing r32 revision with the commit message from the r31 revision.

    Caution:

    Has catched another problem. The git pull origin trunk:master in mine case has reverting changes back before the reindex. So DO NOT DO the pulling. Make the rebase and push before the pull to propogate the fixed changes to the remote repository.

    0 讨论(0)
  • 2020-12-17 09:51

    I believe you want git svn rebase. This is different from git pull, but similar in that both involve two steps (fetch from remote and then rebase or merge).

    You can also rebase only already fetched commits:

    git svn rebase --local
    

    If you have local commits that are not yet in SVN, git-svn will replay (rebase) them on top of the newest SVN commits.

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