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,
This Result - Try this: Simple script one command for git add, git commit and git push
Open your CMD on Windows and paste this answer
git commit -m "your message" . && git push origin master
This example my picture screenshot : https://i.stack.imgur.com/2IZDe.jpg
I have this function in my .bash_profile
or .profile
or .zprofile
or whatever gets sourced in login shells:
function gac () {
# Usage: gac [files] [message]
# gac (git add commit) stages files specified by the first argument
# and commits the changes with a message specified by the second argument.
# Using quotes one can add multiple files at once: gac "file1 file2" "Message".
git add $1 && git commit -m "$2"
}
Check first what aliases you have...
git config --get-regexp alias
If it's not there you can create your own (reference: https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases)
// git add
git config --global alias.a '!git add -A'
// git commit
git config --global alias.c '!git commit'
// git commit -m
git config --global alias.cm '!git commit -m'
// git add commit
git config --global alias.ac '!git add -A && git commit'
// git add commit -m
git config --global alias.acm '!git add -A && git commit -m'
For instance, if you use the last one...
git acm 'My commit'
pretty sure you can use:
git commit -am "commit all the things"
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 will fail for shell expansion on Linux. On Windows, one should use double-quotes (") instead (pointed out in the comments, did not verify).
you can use git commit -am "[comment]" // best solution or git add . && git commit -m "[comment]"