Synchronize git-svn branch with git repository

风流意气都作罢 提交于 2021-01-29 05:09:58

问题


We have a client that has SVN as version control. We have to work with their repository and they don't want to create branches for us, only the branch they deploy, so we cannot create small commits, only a big one when the feature is ready to be deployed.

I've read about git-svn and I think it's almost the perfect solution. But is there a way of synchronizing locally created branches with an external repository? Both to backup and sync with other people.

I mean, you have the SVN repository. Clone it with Git and create a branch (locally, not allowed to do in the SVN repo). Is there a way of making that branch point to any newly created repository. Like a different repository created from that branch.

I hope I could explain it. Is this possible?


回答1:


After you have cloned the subversion repository with something like this

git svn clone -s $SVN_URL proj-clone

you can add a "real" git remote repository:

cd proj-clone
git remote add team $GIT_URL

You have to choose a different remote name than the usual origin because git svn would use the same refs (e.g. refs/remotes/origin/trunk) for tracking as git remote.

After that you can pull/push as usual to the git-remote.


If - on the other hand - you only want to track one branch like this:

git svn clone $SVN_URL/trunk proj-clone

then git svn dos not use the namespace refs/remotes/origin/* but refs/remotes/git-svn. In this case you can use the usual originas the remote name.


In any case: You can modify this by using the --prefix= parameter during git svn clone. (See the docs).



来源:https://stackoverflow.com/questions/53812912/synchronize-git-svn-branch-with-git-repository

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