Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stage and commit all files, including newly added files, using a single command?

Tags:

git

How can I stage and commit all files, including newly added files, using a single command?

like image 987
Anantha Kumaran Avatar asked Mar 10 '10 17:03

Anantha Kumaran


People also ask

What is the command to stage files for a commit?

Stage Files to Prepare for Commit Stage all files: git add . Stage a file: git add example. html (replace example.

What is the git command to add all staged files?

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.


1 Answers

Does

git add -A && git commit -m "Your Message" 

count as a "single command"?

Edit based on @thefinnomenon's answer below

To have it as a git alias, use:

git config --global alias.coa "!git add -A && git commit -m" 

and commit all files, including new files, with a message with:

git coa "A bunch of horrible changes" 

Explanation

From git add documentation:

-A, --all, --no-ignore-removal

Update the index not only where the working tree has a file matching but also where the index already has an entry. This adds, modifies, and removes index entries to match the working tree.

If no <pathspec> is given when -A option is used, all files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).

like image 79
Ian Clelland Avatar answered Oct 03 '22 00:10

Ian Clelland