Rebel or Imperial?

Rebel or Imperial? by alexhung
Rebel or Imperial?, a photo by alexhung on Flickr.

Star Wars Moleskines FTW!

Preparing for emergency

I was in Manhattan 10 years ago. I lived in mid-town and worked one building next to the World Trade Center 2. I watched it happened live on TV. It was the first time I felt I was not prepared at all to deal with an emergency. I did not have a plan. Any plans. Plan for evacuation, plan for communicating to families, plan for getting up-to-date news, plan for no electricity, plan for no water, plan for no food supply, plan for helping others with first aid, plan for, well you get the idea. That was the first time I realized I needed to be prepared for the next emergency, be it a terrorist attack, storm, or earthquake. Alas, life went back to normal and the preparation I’ve managed for the next 8 years were a few large bottles of waters under the kitchen sink.

Read the rest of this entry

Motorsport Photography Workshop at Lime Rock Park

Two weeks ago I attended the Motorsport Photography Workshop at the Lime Rock Park. It was a 2-days workshop with professional instructors (Rick Dole, George Tiedemann and Robert Laberge) leading a class of around 40 students. I actually learnt of it last year but the date clashed with our weekend at the US Open Tennis. This year I signed up for the workshop the moment I received the email alert. I, however, did not sign up for the full 2-days course, only attending the first day. The workshop used the Ferrari Challenge weekend as the source of racing action to teach us how to take action photography, involving head-on shots, panning sideways, compositions, interacting with mechanics and drivers in the pit lane/paddock, etc.

Read the rest of this entry

Jersey City sunset

Jersey City sunset by alexhung
Jersey City sunset, a photo by alexhung on Flickr.

How to nuke a git commit on the remote repo

Here is the situation I ran into this morning. I was happily writing code, periodically pulling changes from GitHub, like a good developer that I am. When I was finally ready to push, I received a merge from GitHub that deleted most of my Django project files. Turns out that one of the other developer on the team accidentally deleted those files and committed it locally. He didn’t push all the commits up to GitHub until just before I tried to push mine (hence I didn’t get any merges from him all morning).

So now I’m in this state where my local repo has a number of commits that I need to push up. But I can’t because I don’t want to merge in all the accidental deletes. I need to remove/fix the deletion first before I can push. How do I do that? After a few minutes on Google, I got the general approach of using git rebase but nothing that points me to actual steps that I think will fix my problem. Then I turned to Twitter, posted a question, and waited while I did some more googling. Low and behold, I received tips from @XTZGZoReX on a possible approach and after I tried it out, it works perfectly!

Here is how:

  1. Leave the existing local repo alone. You may want to reset it back to the pre-merge state by doing git reset --hard
  2. Make a fresh clone of the repo from GitHub. Let’s call it repo2.
  3. Perform an interactive rebase on repo2 and set the starting point to one commit before the one you want to nuke: git rebase -i
  4. The interactive rebase will open up a text editor (vi if you haven’t changed the default configuration) with a list of all the commits starting from the commit you want to nuke to the latest.
  5. Remove the line with the commit you want to nuke (‘dd’ keys in vi) and save the file (‘:wq’ in vi)
  6. Git will now try to apply all the subsequent commits and roll forward to the latest state. In my case, I needed to manually add and remove some files on some of the commits. After each git add/remove, you need to tell git to continue the rebase: git rebase --continue
  7. When all the commits are roll-forwarded by git, push it up to GitHub by doing a force push: git push -f
  8. Now, switch back to your original repo and pull the latest from GitHub. Good chance that you will get merge conflicts. Resolve, commit, and push. And you are done!
Follow

Get every new post delivered to your Inbox.

Join 604 other followers