git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] Re: git-svn: make git-svn commit-diff able to work without explicit arguments

From
Junio C Hamano <junkio@cox.net>
Date
Jan 2, 2007, 22:01 UTC
Message-ID
<7vwt45rsuw.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070102211339.GF17898@hades.madism.org>
Pierre Habouzit <madcoder@debian.org> writes:
Show 10 quoted lines
> ... and
> sometimes think that in a A--B--C--D and in fact, I'd prefer to have:
>
>   {A,C}--B--D. how is it possible to do that in a not too cumbersome
> way? because that would make sens to work in some scratch branch, and
> then reorganize patches in a saner better way in the master branch.
>
>   But I fail to see how to achieve that without using cumbersome
> export-to-patch then git apply patch and edit logs which is painful and
> not really using git.

First of all, "format-patch and then edit" is a perfectly sane way to use git. Any workflow that takes advantage of cheap branch creatin and cheap resetting of the tip of a branch _is_ "really using git". It depends on the size of the series you are redoing, but I do that all the time.

Also cherry-pick, rebase, squash merge are your friends.

If you are on $original branch (which may be your 'master') with commits A--B--C--D:

	git checkout -b temp HEAD~3 ;# that's A
        git cherry-pick $original~1 ;# that's C
	git checkout $original
        git rebase temp
would make the $original A--C'-B'-D'.  Then:
	git checkout temp ; git reset --hard $original~4 ;# parent of A
	git merge -s squash $original~2 ;# squash A and C'

would prepare you to make a squashed commit out of the two to the temp branch. Then:

	git checkout $original
        git rebase --onto temp HEAD~2 ;# that's C'
	git branch -d temp
would give you (A+C)--B'-D' on $original branch.

StGIT would make life even easier for you. It is designed to make things like the above simpler.

Previous: Pierre HabouzitNext: Steve Frécinaux
Message 9 of 10 in “[RFC] git-svn: make git-svn commit-diff able to work without explicit arguments”
  1. Steve FrécinauxJan 2, 2007
  2. [RFC] Re: git-svn: make git-svn commit-diff able to work without explicit argumentsPierre Habouzit, Jan 2, 2007
  3. Eric WongJan 2, 2007
  4. Junio C HamanoJan 2, 2007
  5. [RFC] Re: git-svn: make git-svn commit-diff able to work without explicit argumentsPierre Habouzit, Jan 2, 2007
  6. Brian GernhardtJan 2, 2007
  7. Jakub NarebskiJan 2, 2007
  8. [RFC] Re: git-svn: make git-svn commit-diff able to work without explicit argumentsPierre Habouzit, Jan 2, 2007
  9. Junio C HamanoJan 2, 2007
  10. Steve FrécinauxJan 2, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.