threads / discuss / 16629

Can Git push only first parent history commits?

Subject: Can Git push only first parent history commits?

## tl;dr

5 messages between Dec 8, 2008 and Dec 8, 2008.

replies: 4people: 4as markdown or json

Li Frank· Dec 8, 2008, 02:52 UTC · lore
        The commit history is: 
        origin/master
              Commit1..Commit2..Commit3(T1 branch). 
         
        I want to combined Commit1, Commit2 and Commit3 to one commit_X
and push to origin master and keep old T1 branch history.  So I can't
use rebase.  T1 branch history will be lost after rebase. 
        So I create T2 branch at origin/master:
	
        origin/master
              Commit1..Commit2..Commit3(T1 branch). 
	  T2 (branch).
        Then I use "git merge --no-ff --log T1" merge T1 to T2.  
        So 
	  origin/master
              	+--Commit1..Commit2..Commit3(T1 branch). +
	
+----------------------------------------------------------------+--Comm
itX(T2 branch).
       But when I push T2 to origin master, Commit1 ,2, 3 also pushed.
I expect there are only CommitX at origin master branch. 
       How can I do?
 
best regards
Frank Li
Junio C Hamano· Dec 8, 2008, 03:00 UTC · re: Li Frank · lore

Re: Can Git push only first parent history commits?

Your drawing nor explanation unfortunately does not make much sense to me, so I'll respond only to the subject.

Pushing only first parent history would mean that the commits you will be transferring will still record their true parents, but you are not sending any parents but the first ones. The repository that receives such a push would not pass fsck, in other words, you are deliberately corrupting the repository.

Naturally we won't support such an operation by default.

It is plausible that you can implement an option to do so, but it would make it hard at the receiving end to tell between a true repository corruption and a corruption you are deliberately introducing by such a push, so it won't be useful unless accompanied by a corresponding option to fsck to make it not complain when parent commits and associated objects that are not necessary for first parent history.

Li Frank· Dec 8, 2008, 03:11 UTC · re: Junio C Hamano · lore

RE: Can Git push only first parent history commits?

I don't know the detail of git internal.  Or my email subject
description have some problem. 
 
I just want to combine some commits to one commit and push combined
commit to remote.  And at same time, keep commits history at my local
repository.  Rebase will make original history lost. 
 
-----Original Message-----
From: Junio C Hamano [mailto:gitster@pobox.com] 
Sent: Monday, December 08, 2008 11:00 AM
To: Li Frank-B20596
Cc: git@vger.kernel.org
Subject: Re: Can Git push only first parent history commits?

Your drawing nor explanation unfortunately does not make much sense to me, so I'll respond only to the subject.

Pushing only first parent history would mean that the commits you will be transferring will still record their true parents, but you are not sending any parents but the first ones. The repository that receives such a push would not pass fsck, in other words, you are deliberately corrupting the repository.

Naturally we won't support such an operation by default.

It is plausible that you can implement an option to do so, but it would make it hard at the receiving end to tell between a true repository corruption and a corruption you are deliberately introducing by such a push, so it won't be useful unless accompanied by a corresponding option to fsck to make it not complain when parent commits and associated objects that are not necessary for first parent history.

Matthieu Moy· Dec 8, 2008, 07:44 UTC · re: Li Frank · lore

Re: Can Git push only first parent history commits?

"Li Frank" <Frank.Li@freescale.com> writes:
Show 6 quoted lines
> I don't know the detail of git internal.  Or my email subject
> description have some problem. 
>  
> I just want to combine some commits to one commit and push combined
> commit to remote.  And at same time, keep commits history at my local
> repository.  Rebase will make original history lost. 
git merge --squash may help.
-- 
Matthieu
Boyd Stephen Smith Jr.· Dec 8, 2008, 04:03 UTC · re: Li Frank · lore

Re: Can Git push only first parent history commits?

On Sunday 07 December 2008, "Li Frank" <Frank.Li@freescale.com> wrote about 'Can Git push only first parent history commits?':

Show 7 quoted lines
>        The commit history is:
>        origin/master
>              Commit1..Commit2..Commit3(T1 branch).
>
>        I want to combined Commit1, Commit2 and Commit3 to one commit_X
>and push to origin master and keep old T1 branch history.  So I can't
>use rebase.  T1 branch history will be lost after rebase.

I'm pretty sure you want to do something like this: git branch T2 T1 git rebase -i master T2 # Editor opens # Edit commit list to squash 3 commits into 1. git push origin T2:master git fetch origin

At the end, you'll have a history that looks like:
*--> origin/master (T2)
 \
  -> C1 --> C2 --> C3 (T1)

I'm not sure why you'd want to do this though. If the commits don't stand alone well, they should be squashed on T1 before pushing. If the commits do stand alone well, the history should preserve them on master as well.

-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss03@volumehost.net                      ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.org/                      \_/     

← back to recent threads