Combining local git commits one commit for git-svn

Currently, when git svn dcommit git creates a separate commit in SVN for each local commit I have made since the last synchronization with SVN. Is there a way for dcommit instead combine all my last local commits into a single commit for SVN?

+26
commit git-svn dcommit
Sep 11 '09 at 0:07
source share
6 answers
 git rebase remotes/trunk --interactive 

should bring you to a menu where you can select commits or crush them all in 1 commit so as not to pollute your svn repository. This is a really good (but short) resource when working with git-svn.

+18
Sep 11 '09 at 0:18
source share

No, but you can easily come to terms with all commits. In the following example, I assume that you are on the master branch corresponding to the remote trunk branch and want you to mix all local commits together:

 git tag local # create a temporary tag git reset --hard trunk git merge --squash local git commit # write your single commit message here git svn dcommit git tag -d local # delete the temporary tag named local 

Instead of using a temporary tag, you can also just use reflog (ie use master@{1} instead of local )

+17
Sep 11 '09 at 0:18
source share

When I work with git-svn and want the git series to be displayed as a single commit, I work on the topic branch and then perform a short switch from merge to master before dcommit .

First reinstall the branch on svn and make sure the local wizard is updated:

 git svn rebase && git push . remotes/trunk:master 

Then switch to master, merge and dcommit:

 git checkout master git merge <branch> --no-ff -m "Message you want in svn" git svn dcommit 

This will appear as a single commit in Subversion, but you will still have your local history that would force you to do this.

  +--- Merge commit V svn trunk *---*---*-------------------*--- --- --- \ / topic branch *---*---*---*---* 
+3
Nov 05 2018-10-10T00:
source share

A simpler way could be (if you have many commits in your local system):

 git reset <hash tag of commit till which u need to combine> git commit -am "your message" // This will create one clubbed commit of all the commit till the hash tag used. 
+3
May 26 '11 at 6:34 a.m.
source share

This worked for me - crushed several commits into one commit, and then dcommitted in svn:

http://www.gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html

+2
Nov 05 '10 at 0:00
source share

which does not work for me. I use merge --no-ff --no-commit , but after commit, I got:

 svntrunk 54f35e4 [trunk: ahead 336] release 1 

dcommitting to trunk will commit all 336 commits.

dumping, tagging and crushing, as described in answer # 2: Combine local Git, commit in one commit for git-svn , will work, but the next merge you will have some problem to collect all the commits again!

one that works for me:

 git checkout -tb svntrunk remotes/trunk git merge --no-commit --squash master 

to get all commits from master to svn without losing history for future merge with the same command

~ Marcel

0
Jul 13 '11 at 8:22
source share



All Articles