Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to git add all files in current project, commit, and do a push?

Tags:

git

bash

For smaller personal projects, sometimes I just want to make an instant snapshot of the project, so that I don't lost any files or won't messed up the file contents and can't get it back.

So I hope to have a command that will add all files in the current project (no matter which directory I am in within the project directories), commit them, and push it to a remote server, be it github or gitlab.

Is the following a good way to do it; is there a better way?

alias gitokpush='git add --all :/ && git com -am "ok" && git push'

For the record, :/ means for the whole working directory (the very top), because git add . only adds all files in the current directory and underneath, not necessarily everything from the very top.

like image 636
nonopolarity Avatar asked Jan 28 '26 02:01

nonopolarity


1 Answers

You can also use a git alias:

 git config --global alias.okpush '!'git add --all :/ && git com -am \"ok\" && git push'

Then a git okpush would be enough.

Even shorter (and allowing a custom message)

git config --global alias.cam '!git commit -a -m '

Then: git cam "ok"

like image 149
VonC Avatar answered Jan 29 '26 16:01

VonC