Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git add auto-complete filename

I am working on a git project. Since I have a lot of folder deepness, I would like to improve my auto-completion to work with filenames and not only paths.

Here is an example:

$git status                                                                                                                        1 ↵  ✹master 
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   app/src/main/java/fr/pasteque/client/BaseFlavor.java
    modified:   app/src/main/java/fr/pasteque/client/widgets/RestaurantTicketsAdapter.java

no changes added to commit (use "git add" and/or "git commit -a")

I obviously have to add a file with:

git add app/src/main/java/fr/pasteque/client/BaseFlavor.java

But I would love to be able to write: git add BaseFlavor.java

git add **/BaseFlavor.java works!

But the completion, like git add **/Base<tab>, doesn't..

Any ideas how it can works with completion ?

Thanks in advance!

like image 753
nsvir Avatar asked Aug 03 '15 14:08

nsvir


People also ask

Why do we need to specify filename in Git add?

This is the reason you need specify filename in git add command. After you tell git which file should be managed by git add <filename>, you can use git add -u to stage your modification, in this case, filename is not necessary. simply you can use . You can use git add . this will take entire directory / new files / modified files - ready to commit.

How can I autocomplete Git commands and branch names?

In a terminal on Mac OS X, you can use [TAB] to autocomplete file names and file paths. Wouldn’t it be nice if you could do the same with git commands and branch names? Get the git-completion.bash script and put it in your home directory: Make sure that you are in your home directory: Add the following code to your .bash_profile (~/.bash_profile).

How do I add a specific file to a Git file?

git add A Folder or Specific File. The safest and clearest way to use git add is by designating the specific file or directory to be staged. The syntax for this could look like: git add directory/: Stage all changes to all files within a directory titled directory.

Why does Git add fail to add Ignored files?

The git add command will not add ignored files by default. If any ignored files were explicitly specified on the command line, git add will fail with a list of ignored files.


1 Answers

Try git add **/Base*<tab> (notice the additional *).

like image 58
Arkanosis Avatar answered Sep 19 '22 17:09

Arkanosis