Is it possible to make git svn dcommit result in one svn commit?

According to the manual , git dcommit "will create a revision in SVN for every commit in git." But is there a way to avoid multiple revisions of Subversion? That is, to git merge all changes before executing svn commit ?

+42
git svn git-svn
01 Oct '08 at 16:31
source share
3 answers

If you work with a branch in git, you can git-merge --squash , which does it in git. Then you can push this compressed commit to SVN.

Of course, many small commits are good, so why do you need to tweak them?

+34
01 Oct '08 at 16:43
source share

The git rebase -i can do this and more. This team is extremely powerful, so it's good to make friends with it.

Syntax: git rebase -i <commit ID> . This calls your text editor with parameters (and instructions) to change all commits to (not including) the given identifier.

For example, to change the previous 5 commits, you can do this:

git rebase -i HEAD~5

Or, if your SVN branch is called "svn / trunk", then this syntax is good too:

git rebase -i svn/trunk

Then a text editor window will appear. To crush everything, change the first word of each line after the first from "pick" to "squash" (if that sounds confusing - it will make more sense when you see it). Then save and close the editor. You will then have the opportunity to edit the commit message for the compressed commit.

Other things you can do with git rebase -i are reordering commits, dispensing commits in different ways, and deleting commits.

I constantly use this command; this is a git killer feature.

+27
Oct 02 '08 at 18:01
source share

Ryan Tomayko wrote a little about git rebase -i , which he said:

... [this] is a bit like git commit -amend, accumulated on acid and holding a chainsaw - completely insane and quite dangerous, but able to expose completely new states of mind. Here you can edit, squash, reorder, tease, and comment on existing commits in such a simple and intuitive way as it should be.

I have a tendency to commit frequently in git, but I don’t necessarily want to dcommit every svn commit, and crush all my work just as little. I am trying now to reorder and squander a few together into more logical commit blocks.

+7
Dec 13 '08 at 21:00
source share



All Articles