pardon the newbie question. I'm looking for a quick but safe option to add all unstaged/untracked files (returned by "git status") with one command. Is it safe to use from the project root:
git add *
Any drawback? Thanks
* is a wildcard expanded by the shell. It won't match "hidden" files (those whose names start with .) and it will fail if there are too many files in the current directory to fit on the command line.
A solution without these drawbacks is:
git add .
This works because git adds the contents of directories recursively, so telling it to add . (the current directory) adds everything.
Another difference relates to .gitignore patterns. If you have a file in the current directory that matches a pattern in .gitignore, then git add . will just silently ignore it. But shell wildcards don't know about .gitignore, so when you do git add *, the ignored file will be explicitly added to the git add command, which causes git add to fail with an error.
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