How to deal with a git that has git-svn and pure git remotes

纵然是瞬间 提交于 2020-02-06 04:11:41

问题


I have two repositories, one is still an svn and acts as the main place, and another is pure git where is the daily work. I've my local clone using git svn clone svn+ssh://... and adding a remote using git remote add git@....

After a refactoring with its commits and branches, the git master has the directory structure modified and when I try to git svn dcommit a bunch of conflicts arise in what looks like a rebase to the svn. It's like the mv of files and directories to rename and relocate are lost.

The solutions I'm reading looks that comes from scenarios where both remote are being committed at the same time, and even this can cause issues. Is there a way to tell git-svn to act like strategy is to convert the svn to what git has?

Update @ 20140821

After a while I've found how it can work for me, but I'm not sure this would be enough generic.

In my case I'm having both remotes with the same commits, that is when I do a push just before or after I'll do a dcommit. Then I can force myself to always start by the git and then continue with svn.

It looks like:

git svn fetch
git fetch gitremote
git add file1 file2
git commit -m "something descriptive but concise"
git push gitremote branch
git svn dcommit

The only way I've found sending the commit first to svn, is to use the option --force in the push, because otherwise the statuscommand was including a message:

# Your branch and 'gitremote/branch' have diverged,
# and have 3 and 2 different commits each, respectively.

And any try to merge shows all the changes made in the commit like new. But this force looks to have a big issue if there are other changes in the git repository (for example another developer has already pushed something there), then this force may overwrite those changes.


回答1:


To avoid history rewrite (git push) on the git remote side you could simply do a merge. In the simplest case, where you have pushed your changes to svn/branch and have a corresponding git_remote/branch with no difference:

git checkout git_remote/branch
# -s ours to ignore potential conflicts, assuming git diff is empty
git merge -s ours svn/branch
git push git_remote HEAD:branch  


来源:https://stackoverflow.com/questions/25137439/how-to-deal-with-a-git-that-has-git-svn-and-pure-git-remotes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!