Git: init, add everything and commit with a message in one command

How can I group these 3 commands:

  • git init
  • git add .
  • git commit -m "Initialize repository"

I have this, of course, but I'm looking for something shorter and more elegant if it exists:

me@local:~$ git init; git add .; git commit -m "Initialize repository"
+4
source share
1 answer

Create an alias:

git config --global alias.here '!git init . && git add . && git commit --allow-empty -m "Initialize repository"'

then use it like

git here

Please note that I added the parameter --allow-emptyto git commit, which will allow working in an empty directory, as well as with the contents.

+5
source

All Articles