Skip to content

Instantly share code, notes, and snippets.

View ivanvanderbyl's full-sized avatar
🏔️

Ivan Vanderbyl ivanvanderbyl

🏔️
View GitHub Profile
keithpitt = RubyHacker.with_attributes({
performs_magic_tricks: true,
beard_profile: 'recently nearly removed it by accident',
perth_resident_status: 'recently moved there',
open_source_contributor_status: 'awesome'
})
keithpitty = RubyHacker.with_attributes({
performs_magic_tricks: false,
beard_profile: 'first grew a beard before keithpitt was born',

Rebasing Merge Commits in Git

This morning I discovered a nasty little problem with git-rebase that can have pretty unexpected and unwanted results - how it handles a merge commit.

The TL;DR version is this: Always use git rebase -p

Why I use pull --rebase

I think a lot of people are using git pull --rebase as their default to avoid unnecessary merge commits when fetching the latest code from master. There are a few blog posts on the matter, such as [1] [2]

Reverting multiple commits

Realised you can use git-reset in a funky way if you're trying to repair a repo that's got into a dodgy state. If you're working locally, you can use git reset --hard or git rebase -i or whatever to rewrite your history (if you're into that sort of thing) but when the commits have already been pushed things are slightly more complicated.

TL;DR

git reset --hard last_good_commit
git reset --soft ORIG_HEAD
git commit -m 'threw away changes back to last_good_commit'

git push

/*
The MIT License (MIT)
Copyright (c) 2014 Ismael Celis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@tmm1
tmm1 / passenger.rb
Created July 25, 2009 04:55
eventmachine monkey-patch for passenger
# Monkey-patch for Passenger to use the EventMachine reactor.
# This allows the use of EM timers, EM.system/popen, and other async libraries (amqp, em-http-request, etc) inside a Rails process.
# This requires EM.watch which was added to EM's git repo recently. Build an EM gem first:
# git clone git://github.com/eventmachine/eventmachine
# cd eventmachine
# gem build eventmachine.gemspec
# sudo gem install eventmachine-0.12.9.gem
# Please do not use this in production =)