How often do you see the following?

commit abcdefg123456789
Merge: 1234567 abcdefg
Author: Joe Disco <joe@wearstightpants.com>
Date:   Wed Aug 4 11:16:24 2010 +0100

    Merge branch 'master' of git@github.com:levent/meaningoflife into master

I see this common workflow in most teams and my guess is that yours could be similar?

git pull
[write some code]
git add
git commit
git push # rejected as some doucheinspiring individual has decided to push to origin/master in the meantime
git pull # introduce the shitty merge commit
git push # you've pushed your commit plus the shitty merge making you a douche
[everyone hates you as much as you hate them]

Eventually the whole repository is cluttered with meaningless commits.

I generally work in a temporary local branch if my work is likely to take some time (say longer than a pomodoro - 25 mins) and avoid this issue by constantly keeping master up to date through git rebase.

Occassionaly I don’t feel the need (or I forget) to create a feature branch so I work on master (or whatever is your team’s main commit branch).

I have modified my personal workflow to avoid merge commits as follows but it feels slightly ridiculous. There must be an easier way?

Over-the-top workflow:

git pull
[write some code]
git add
git commit
git push # rejected but you remain calm this time
git checkout -b sometemporarybranch # move your commits over to a temporary branch
git checkout master
git reset --hard origin/master
git pull origin master
git checkout sometemporarybranch
git rebase master
git checkout master
git merge sometemporarybranch
git push
git branch -D sometemporarybranch
[high fives all around]

This works for me but feels long-winded and my guess is there is a far simpler way of doing this with git 1.7.x.

Who knows how?

Update

Thanks to Paul Battley @threedaymonk and Andy Roberts @baob this can all be accomplished as follows:

[write some code]
[commit code locally]
git fetch
git rebase origin/master
git push

Further update

Thanks to Craig Webster @craigwebster and Mutwin Kraus @mutle this can even be shortened to:

[write some code]
[commit code locally]
git pull --rebase

see the comments for more info and gotchas

Levent Ali · 4 August 2010 · git scm code

I recently decided that it was about time I separate my portfolio work from the amount of other rubbish I store on my flickr account.

There’s still much curation that needs to be done, which is something I struggle with, but hopefully the set will evolve into something I can be proud of over the next few weeks and months.

So without further ado, I hope you enjoy my portfolio of portraits.

Levent Ali · 2 May 2010 · photography

Recently I’ve been using the Sleep Cycle alarm clock iPhone application. The app uses the iPhone’s accelerometer to analyse your sleep and wake you up when you are in a light sleep phase (near your specified alarm time).

This morning I noticed some amusing patterns based on my state prior to going to bed.

It’s worth noting that I have a broken clavicle so I do not move too much whilst resting.

A regular night

Regular night sleep stats

Speaks for itself and most of my graphs look like this.

After a dose of paracetamol+codeine and muscle relaxants

I was in a lot of pain one evening so took the prescription medication before retiring.

Codeine night sleep stats

Out cold!

After having a bit too much to drink

It was a friend’s 30th birthday last night so I had a few alcoholic beverages.

Alcohol night sleep stats

I woke up lying on my broken side with the duvet lying on the floor.

Levent Ali · 18 March 2010 · personal sleep charts

Serenade me with Whitney Houston’s “How Will I Know” and I’m yours.

Levent Ali · 17 February 2010 · music

After months of O2 broadband woes I decided to leave. Their final attempt at resolution was to reduce my bandwidth to such a low level that dropped connections became rare (a couple of times a day as opposed to several times a minute whilst at 8Mb). Of course they lied about this and I was still paying for 8Mb.

After years of dissatisfation with O2’s mobile phone network coverage I decided to request my PAC Code and return to my old operator.

  • Hi, could you send me my PAC Code please.
  • May I ask why you are leaving?
  • I'm unhappy with your network coverage and have had a bitter experience with O2 broadband as well.
  • Have you opened a case with us and had us help you with your problems? After all it's our job to support you. Besides, broadband is a separate franchise.
  • There's no point because everyone I know on O2 has the same coverage issues across the same locations. It's not the handset, it's definitely the network. Besides, you're all O2 to me regardless of the franchise structure.
  • Attempts to convince me to let them 'have a go'
  • No thanks. I just want to leave.
  • I find your behaviour to be bizarre. Do you turn your back on all relationships at the first sign of conflict without allowing any attempt at resolution?
  • Give me my PAC Code now.

Joke is on me?

Levent Ali · 17 February 2010 · customer service

☜ newer posts older posts ☞