threads / discuss / 24276

how do I exclude a commit from set of commits to be pushed.

Subject: how do I exclude a commit from set of commits to be pushed.

## tl;dr

5 messages between Jul 3, 2010 and Jul 6, 2010.

replies: 4people: 3as markdown or json

Mahesh Vaidya· Jul 3, 2010, 15:35 UTC · lore
In the series of commits C1..C8 how do I exclude a commit to be pushed.

use case - I have commits say C1..C8 to be pushed. Due to my pre-receive hook commit C4 is complying with commit standard. I have amended C4 to C5 ; still C4 shows up in commits to be pushed list.

git reflog delete --rewrite and git gc --prune did not help

Thx/ Mahesh --

Johan Herland· Jul 3, 2010, 16:04 UTC · re: Mahesh Vaidya · lore

Re: how do I exclude a commit from set of commits to be pushed.

On Saturday 03 July 2010, Mahesh Vaidya wrote:
Show 10 quoted lines
> In the series of commits C1..C8 how do I exclude a commit to be pushed.
> 
> use case -
> I have commits say C1..C8 to be pushed. Due to my pre-receive hook
> commit C4 is complying with commit standard. I have amended C4 to C5 ;
> still C4 shows up in commits to be pushed list.
> 
> git reflog delete --rewrite and git gc --prune did not help
> 
> Thx/ Mahesh

You probably want to squash C5 into C4. Look up 'git rebase --interactive', and the 'squash' instruction. A good intro can be found at either http://book.git-scm.com/4_interactive_rebasing.html or http://progit.org/book/ch6-4.html

In general, it seems you have misunderstood the purpose of the reflog. The reflog only keeps track of where your HEAD has pointed previously, and what operations you have done. Rewriting the reflog does NOT change the actual commit, nor does it rewrite your commit history in any way. In other words, there is nothing you can do to the reflog that will affect what you push.

You may want to read the entire Pro Git book ( http://progit.org/book/ ) to get a firm grip on the Git object model.

...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Mahesh Vaidya· Jul 3, 2010, 17:37 UTC · re: Johan Herland · lore

Re: how do I exclude a commit from set of commits to be pushed.

Hi

Thank for the pointer; Do you think following scriptlet is good for modifying specific commit ? and do edit.

cat ./modify_specific.sh git rebase -i $1 && git commit --amend && git rebase --continue

Thank you in advance -Mahesh

Show 5 quoted lines
> You probably want to squash C5 into C4. Look up 'git rebase --interactive',
> and the 'squash' instruction. A good intro can be found at either
> http://book.git-scm.com/4_interactive_rebasing.html or
> http://progit.org/book/ch6-4.html
>
Show 11 quoted lines
>
> You may want to read the entire Pro Git book ( http://progit.org/book/ ) to
> get a firm grip on the Git object model.
>
>
> ...Johan
>
> --
> Johan Herland, <johan@herland.net>
> www.herland.net
>
-- 
Thank you and best regards.
Mahesh Vaidya  / 9740500144
http://www.twitter.com/forvaidya
Johan Herland· Jul 3, 2010, 20:39 UTC · re: Mahesh Vaidya · lore

Re: how do I exclude a commit from set of commits to be pushed.

On Saturday 03 July 2010, Mahesh Vaidya wrote:
Show 5 quoted lines
> Thank for the pointer; Do you think following scriptlet is good for
> modifying specific commit ? and do edit.
> 
> cat ./modify_specific.sh
> git rebase -i $1 && git commit --amend && git rebase --continue

You would need to do "$1^" instead of $1, since 'rebase' works on all commits _since_ the given commit (i.e. not including the given commit). You will also have to change the first line of the rebase "script" that is opened in your editor (from "pick <sha1> to "edit <sha1>").

...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Eric Raible· Jul 6, 2010, 19:04 UTC · re: Johan Herland · lore

Re: how do I exclude a commit from set of commits to be pushed.

Johan Herland <johan <at> herland.net> writes:
Show 6 quoted lines
> 
> On Saturday 03 July 2010, Mahesh Vaidya wrote:
> > git rebase -i $1 && git commit --amend && git rebase --continue
> 
> You would need to do "$1^" instead of $1, since 'rebase' works on all 
> commits _since_ the given commit (i.e. not including the given commit)....

The above will suffice if you just want to change the commit message. If you want to change file contents you'll need a 'git add' as well.

← back to recent threads