Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

Is there any way I can do

git add -A

git commit -m "commit message"

in one command?

I seem to be doing those two commands a lot, and if Git had an option like git commit -Am "commit message", it would make life that much more convenient.

git commit has the -a modifier, but it doesn't quite do the same as doing git add -A before committing. git add -A adds newly created files, but git commit -am does not. What does?

1 Answer

+1 vote
by (62.9k points)

You can use git aliases, e.g.

git config --global alias.add-commit '!git add -A && git commit'

and use it with

git add-commit -m 'My commit message'

EDIT: Reverted back to ticks ('), as otherwise, it'll fail for shell expansion on Linux OS. Use double-quotes (") instead, if you are using OS like windows.

by (19.7k points)
This solution helped me!

Browse Categories

...