Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It's really tedious to type the following command:

git checkout 622fe0a9b6bffdf4723026ae6e673245b510ac66

Is there autocomplete or shortcut to do this?

share|improve this question

migrated from stackoverflow.com Aug 22 '12 at 6:57

This question came from our site for professional and enthusiast programmers.

1  
@Mechanicalsnail I'm using oh my zsh! – mko Aug 21 '12 at 5:04
up vote 4 down vote accepted

Note that you have a ton of shortcuts which avoid entering the SHA1 altogether.

The short SHA1 are mentioned in "Git Tools - Revision Selection", but git rev-parse section on "SPECIFYING REVISIONS" mentions also (small extract):

  • master@{5}: the 5th prior value of master
  • master~3 A suffix ~<n> to a revision parameter means the commit object that is the <n>th generation ancestor of the named commit object
  • :/fix nasty bug names a commit whose commit message matches the specified regular expression
  • master@{yesterday}, HEAD@{5 minutes ago}: specifies the value of the ref at a prior point in time.
  • ... and so on.

So if you known when or where you old commit is based on the current branch, for instance, you have other options.

share|improve this answer
    
+1. I'd recommend that you get familiar with the treeishes VonC has linked to in his answer. They're much more effective than partial or complete SHAs. – Noufal Ibrahim Aug 21 '12 at 5:41
    
+1 for life saver! – mko Aug 21 '12 at 5:43

If you only enter the first few characters, it'll work as long as it's unambiguous.

share|improve this answer
    
Copy/paste seems to be the fastest way ;) But yes, you can just type in the first X characters until you have specified an unambiguous commit ID. I've never had to enter more than 6 characters. – MichaelM Aug 21 '12 at 4:27
    
thanks for this tips – mko Aug 21 '12 at 5:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .