Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: hash autocomplete

Is there any chance to configure git to autocomplete the hashes when pressing TAB?

Edit:

Please note that this question is not about autocomplete, but about hash autocomplete. See my comment to VonC's answer.

like image 566
takeshin Avatar asked Sep 21 '10 11:09

takeshin


2 Answers

You can refer to a commit by only its first few characters: git will autocomplete internally:

git checkout 9771

Thus, you actually don't have to enter the full hash!

like image 90
Eric O Lebigot Avatar answered Oct 12 '22 15:10

Eric O Lebigot


If you have to consider all hashes from your repo, this is not likely because it wouldn't scale well (if you have several hundreds of commits, tags, ... each with their own hashes, this would quickly take a long time to list them all unless you have some caching system for this hash list)

If you limit the hashes to a fairly recent list (on the current branch for instance), may be, but that won't cover all use cases.

You have here an example of git shell with different kind if tab expansion (in PowerShell), further enhanced here.
Even if your environment has no use for PowerShell, that gives you an idea of "tab expansion" implementation.

like image 20
VonC Avatar answered Oct 12 '22 14:10

VonC