One of the commands I find incredibly useful in Git is git add -u
to throw everything but untracked files into the index. Is there an inverse of that?
Such as a way to add only the untracked files to the index without identifying them individually?
The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area. We also say that they will be staged.
So, if you run git add . within a sub directory, it won't add changes to files outside that sub directory. Second, git add . adds both tracked and untracked files.
In order to stash untracked files, add the “–include-untracked” option to your “git stash” initial command. Alternatively, you can simply use the “-u” which is equivalent to the untracked longer version.
yes you can push only the files which you have commited before. you can leave the untracked files and adapt them later.
git ls-files -o --exclude-standard
gives untracked files, so you can do something like below ( or add an alias to it):
git add $(git ls-files -o --exclude-standard)
It's easy with git add -i
. Type a
(for "add untracked"), then *
(for "all"), then q
(to quit) and you're done.
To do it with a single command: echo -e "a\n*\nq\n"|git add -i
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