开发者

Cherry-picking from git to svn (or, How to keep a project history in git and releases in svn)

开发者 https://www.devze.com 2022-12-23 17:14 出处:网络
I\'m in a position where I\'m the only one using git, everybody else is using svn. I\'ve used \'git svn\' to connect to the team svn and mostly it works jus开发者_运维问答t fine. Lately, I\'ve started

I'm in a position where I'm the only one using git, everybody else is using svn. I've used 'git svn' to connect to the team svn and mostly it works jus开发者_运维问答t fine. Lately, I've started a project initially on my own, separate git repo and now I need to merge stuff from it to the svn. However, I still would like to keep tweaking the implementation in my own privacy between releases.

So, what would be the most straightforward way to cherry-pick some commits from my private repo to the svn-cloned repo? Requirement is to keep full local history and have only one svn commit for each pick. Or is there some squashing to be done?

As a method to achieve this, is there a way to get the private repo as another origin for the svn-cloned repo?


You could try to git graft the commit from your Git repo to the commit of the git-svn repo before git dcommit the git svn repo.

The commit from your repo could be isolated in a special branch, when all kind of squashing can take place in order to export a cleaner history.


If you're the only person using the git repo at the moment, you could consider rebasing all your work on top of the empty subversion clone you've created. Then set up a branch to hold your pushes back to subversion, squash each release onto it and commit it back to SVN.

For a more in-depth solution, consider using git commit-tree directly -- provide it with the tree you want to commit (found by running git show --format=raw HEAD and looking at the second line ("tree")), the correct parent commit (whatever's currently in subversion) and the right log message on stdin. This is using the plumbing directly, you probably want to write a script to do it for you... The effect is that you've created a new commit containing the file contents of an existing commit (compare with cherry-pick, which takes the diff added by an existing commit, rather than copying the tree).

0

精彩评论

暂无评论...
验证码 换一张
取 消