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,
git commit -am "message"
is an easy way to tell git to delete files you have deleted, but I generally don't recommend such catch-all workflows. Git commits should in best practice be fairly atomic and only affect a few files.
git add .
git commit -m "message"
is an easy way to add all files new or modified. Also, the catch-all qualification applies. The above commands will not delete files deleted without the git rm
command.
git add app
git commit -m "message"
is an easy way to add all files to the index from a single dir, in this case the app
dir.
I hope this helps someone and please feel free to edit or improve. I'm not sure what the fastest way is but this certainly simplifies my code commit process by using "ohmyzsh" for Git.
git add .
is shortened to ga .
git commit -m "message"
is shortened to gc -m "message"
git push
is shortened to gp
git fetch
is shortened to gf
git pull origin master
is shortened to ggl master
git push origin master
is shortened to ggp master
git checkout -b
is shortened to gcb
git merge
is shortened to gm
git remote
is shortened to gr
git status
is shortened to gst
Create an alias in bash:
alias gac="git add -A && git commit -m"
(I chose to call the shortcut 'gac' but you don't have to)
Use it: gac 'your commit message here'
This works for me always please run following commands:
1.git add .
2.git commit -m "no bugs please"
3.git push origin *
where * is based off the branch you are pushing to, and also commit messages can always be changed to suit the context.
Only adapting the Ales's answer and the courtsimas's comment for linux bash:
To keep it in one line use:
git commit -am "comment"
This line will add and commit all changed to repository.
Just make sure there aren't new files that git hasn't picked up yet. otherwise you'll need to use:
git add . ; git commit -am "message"
I use the following alias for add all and commit:
git config --global alias.ac '!git add -A && git commit -a'
Then, by typing:
git ac
I get a vim window to get more editing tools for my commit message.