Search code examples
gitmsysgit

Quick way to refer to files using git on command line


Suppose I have a source file that I want to stage via git add in the following path:

Foo/Bar/Something/SomethingReallyLong/Very/Deep/In/Folder/Structure/Code.cpp

Inside the directory where this file resides, there will be other files that I do not want to stage yet. I was hoping there was a quick tab completion solution for this, or some other shortcuts. Example:

git add Code.cpp

If I do this, and Code.cpp is the only file in the entire list of unstaged files that has this name, it should automatically know to resolve its path without me having to type it.

Or, perhaps after typing "Code.cpp" I can press TAB and it will resolve the path for me before I hit ENTER. I'm looking for some little tricks like this. Anyone know some practical workflow shortcuts for every day operations like this? I don't want to have to type the whole path :(

I would also hope such shortcuts work on other commands like diff.

Note I'm using msysgit on Windows (1.8.4)


Solution

  • I'm going to answer my own question. Since having posted this, I learned about git-number. This will allow me to do a special git status that puts a number to the left of each file. You can then refer to those files using that number instead of typing the full path.