Re: [exim-dev] Git changes, viewing and pushing

Top Pagina
Delete this message
Reply to this message
Auteur: David Woodhouse
Datum:  
Aan: Phil Pennock
CC: exim-dev
Onderwerp: Re: [exim-dev] Git changes, viewing and pushing
On Tue, 2010-08-03 at 13:11 -0400, Phil Pennock wrote:
> Perhaps I just need more sleep than a leaking air-mattress provides, but
> could a Git expert please help me with two points?
>
>  (1) How to view which changes are in one repository but not another?
>      It's acceptable for the answer to involve my learning about
>      branches in Git and pulling multiple origins to local and diffing
>      them.

>
>      For seeing what's in /users/pdp/exim.git on tahini but not in the
>      master, there must be a better way than looking at the shortlogs of
>      both and trying to spot which changes have and have not made it in?


Often you'll find you have a branch (such as 'origin') which refers to
the upstream tree and you can just do 'gitk origin..' to see what you've
changed locally.

If you don't have such a convenient label you can still use the hex ID
of the commits. gitk 5631d794..

> (2) Selectively pushing commits: how?
>
>      Given four commits in the local tree, replicated to pdp@tahini's
>      tree, *three* of which I wish to push to the master, how do I push
>      those commits?

>
>      For the remaining commit, once that's done, what's the correct way
>      to get rid of it as bad work?  Nuke the repository and re-clone?
>      Rollback?


'git reset --hard HEAD^' will revert to the state before the latest
commit. Or use the hex ID of the commit you want to revert to, or any
other way of identifying a commit.

Note that you'll also overwrite any pending changes in your working tree
when you do this.

Then you can push the bits you wanted.

Sometimes I run gitk to see what's currently in the tree, and reset back
to the origin. Then individually cherry-pick commits with git
cherry-pick in the order I want them, and push the result. There's a
'git rebase --interactive' which makes this prettier, but perhaps harder
to understand what's going on.

--
dwmw2