Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: init, add all and commit with message in one single command

Tags:

git

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 & more elegant if that exists:

me@local:~$ git init; git add .; git commit -m "Initialize repository"
like image 668
Nabil Kadimi Avatar asked Jan 09 '14 16:01

Nabil Kadimi


1 Answers

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

Note that I added the --allow-empty option to git commit, which will let this work in an empty directory as well as one with content.

like image 193
Chris Avatar answered Sep 20 '22 13:09

Chris