Is it possible to skip the staging area and (also) commit untracked, new files to git in a single built-in, command-line command ? If not, what are the alternatives ?
http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository
Providing the -a option to the git commit command makes Git automatically stage every file that is already tracked before doing the commit, letting you skip the git add part:
$ git commit -a -m 'added new benchmarks'
Thanks.
NOTE: Only tracked files can skip the staging area, to add your file to tracker type “git add --a” or “git add filename. extension”. Now let's skip the staging by typing “git commit -a -m “Commit Message””. Now if we do “git status” it will show that the working directory is clean.
Second, git add . adds both tracked and untracked files. Let's demonstrate this, by creating a file in the current directory as well as a file in a sub-directory. Now let's change into the sub-directory and run git add .
To fix this error, either add the files causing the error to the staging area or ignore them using the . gitignore file.
Using a single, built-in, command-line command? No.
Using two commands:
git add -A
git commit
Using a custom alias:
Add this to .gitconfig:
[alias]
commituntracked = "!git add -A; git commit"
Then you can do
git commituntracked
This might seem quite trivial for the gurus, but is a minor revelation to me (I admit) - at least I just used it for the first time now and it works (without custom aliases): Just use a semicolon ;
and it'll work as a one-liner:
git add --all; git commit -m "some informative commit message"
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