On Wed, May 11, 2011 at 11:29:22AM +1000, Erik de Castro Lopo wrote:
> I am not a newcomer to revision control (currently use bzr, darcs
> and svn regularly, started using DVCSs with GNU Arch in 2004) but
> I'm still having trouble coming to grips with git and github.
> 
> On github, I have forked a repo and then cloned it locally. I am
> now setting out to add a feature to this project. This is going
> to take me a while and upstream is changing quite rapidly so I'm
> going to need to constantly pull in upstream changes.
> 
> When I'm done adding my feature, I'd like to send the upstream
> maintainer a clean github merge request. In particular, I would
> prefer that it doesn't contain two weeks worth of daily 'merge
> from upstream' commits.
> 
> Yes, there is acres of git documentation out there but although
> I've spent 10 times as much time reading git documentation as I
> have reading either bzr or darcs documentation, I still find bzr
> and darcs an order of magnitude easier to use.
> 
> A simple recipe of how to do this without burning my fingers
> would be appreciated.

Assume you've already done this bit

  git clone https://github.com/johnf/haml
  cd haml

You then want to add your upstream

  git remote add upstream https://github.com/nex3/haml
  git fetch upstream

You then want another branch to do your feature in

  git co upstream/master
  git branch feature
  git co feature

You would then commit away as normal. Every now and then you might
want to rebase against upstream so that you are always working against
their latest code base

  git fetch upstream
  git rebase upstream

This might dump you into a shell of there are conflicts

  vi
  # Resolve conflict
  git commit -a
  git rebase continue

Now let's assume the feature is finished and you want to merge some
commits and edit some commit messages etc Basically you rebase as
above but in interactive mode e.g.

  git rebase -i

This will through you into $EDITOR with a list of each commit.

If there is a commit you want to throw away then just delete that line

If you want to squash a commit into the previous one then change
commit to squash

You can change commit messages with reword

You can even reorder the commits.

There is some help at the bottom that explains some more options.

Cheers,
John


-- 
John
Blog                             http://www.inodes.org
LCA2012                          http://lcaunderthestars.org.au
_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders

Reply via email to