threads / discuss / 27842

How to push the very last modification only ?

Subject: How to push the very last modification only ?

## tl;dr

4 messages between Jul 18, 2011 and Jul 19, 2011.

replies: 3people: 3as markdown or json

J. Bakshi· Jul 18, 2011, 07:47 UTC · lore
Hello list,
I have found that during push, all local commit goes into the git server. Where I like to only push the very last modification with a meaningful comment which will be available at the git server. How can I then push only the last modified one ?
Thanks
Chris Packham· Jul 18, 2011, 08:58 UTC · re: J. Bakshi · lore

Re: How to push the very last modification only ?

Hi,
On 18/07/11 19:47, J. Bakshi wrote:
> Hello list,
> 
> I have found that during push, all local commit goes into the git 
> server.

Yes that's the normal behaviour. When you think about what push is doing it's trying to make the remote branch the same as your local branch.

> Where I like to only push the very last modification with
> a meaningful comment which will be available at the git server. How
> can I then push only the last modified one ?

This is easily doable. What you need to do is prepare a branch that you do want to push. Something like this, assuming that your current branch is 'master' and you want to push to origin/master:

  # first create temporary a branch to use while you're delivering
  git checkout -b delivery origin/master
  # now cherry pick the commits you do want to push. I usually use
  # gitk and cherry-pick from the right-click menu, but for simplicity
  # I'll use git cherry-pick here.
  git cherry-pick master
  # you can provide a commit id instead of 'master'.
  # at this point you could also use git commit --amend to add any
  # final tweaks to the commit
  # check that your delivery branch is good using git log/gitk. Build,
  # test, etc
  # now push it to your local delivery branch to the remote master
  # branch
  git push origin delivery:master
  # now do some cleanup
  git checkout master
  git branch -d delivery
  git rebase origin/master
Drew Northup· Jul 18, 2011, 16:49 UTC · re: Chris Packham · lore

Re: How to push the very last modification only ?

On Mon, 2011-07-18 at 20:58 +1200, Chris Packham wrote:
Show 18 quoted lines
> Hi,
> 
> On 18/07/11 19:47, J. Bakshi wrote:
> > Hello list,
> > 
> > I have found that during push, all local commit goes into the git 
> > server.
> 
> Yes that's the normal behaviour. When you think about what push is doing
> it's trying to make the remote branch the same as your local branch.
> 
> > Where I like to only push the very last modification with
> > a meaningful comment which will be available at the git server. How
> > can I then push only the last modified one ?
> 
> This is easily doable. What you need to do is prepare a branch that you
> do want to push. Something like this, assuming that your current branch
> is 'master' and you want to push to origin/master:
<snip>

Another way to do what Chris describes is to use Interactive Rebase (git rebase -i) to squash commits together. Please read the manual page for that carefully before using it on a production repository.

-- 
-Drew Northup
________________________________________________
"As opposed to vegetable or mineral error?"
-John Pescatore, SANS NewsBites Vol. 12 Num. 59
J. Bakshi· Jul 19, 2011, 06:07 UTC · re: Chris Packham · lore

Re: How to push the very last modification only ?

On Mon, 18 Jul 2011 20:58:51 +1200 Chris Packham <judge.packham@gmail.com> wrote:

Show 44 quoted lines
> Hi,
> 
> On 18/07/11 19:47, J. Bakshi wrote:
> > Hello list,
> > 
> > I have found that during push, all local commit goes into the git 
> > server.
> 
> Yes that's the normal behaviour. When you think about what push is doing
> it's trying to make the remote branch the same as your local branch.
> 
> > Where I like to only push the very last modification with
> > a meaningful comment which will be available at the git server. How
> > can I then push only the last modified one ?
> 
> This is easily doable. What you need to do is prepare a branch that you
> do want to push. Something like this, assuming that your current branch
> is 'master' and you want to push to origin/master:
> 
>   # first create temporary a branch to use while you're delivering
>   git checkout -b delivery origin/master
> 
>   # now cherry pick the commits you do want to push. I usually use
>   # gitk and cherry-pick from the right-click menu, but for simplicity
>   # I'll use git cherry-pick here.
>   git cherry-pick master
>   # you can provide a commit id instead of 'master'.
> 
>   # at this point you could also use git commit --amend to add any
>   # final tweaks to the commit
> 
>   # check that your delivery branch is good using git log/gitk. Build,
>   # test, etc
> 
>   # now push it to your local delivery branch to the remote master
>   # branch
>   git push origin delivery:master
> 
>   # now do some cleanup
>   git checkout master
>   git branch -d delivery
>   git rebase origin/master
> 
> 
It works !! Many many thanks :-)

← back to recent threads