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!
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.
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).
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.
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.
Try git add **/Base*<tab>
(notice the additional *
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With