Git:init,在一个命令中添加all并使用message进行提交

Nab*_*imi 4 git

如何对这3个命令进行分组:

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

我当然有这个,但如果存在,我正在寻找更短更优雅的东西:

me@local:~$ git init; git add .; git commit -m "Initialize repository"
Run Code Online (Sandbox Code Playgroud)

Chr*_*ris 5

创建别名:

git config --global alias.here '!git init . && git add . && git commit --allow-empty -m "Initialize repository"'
Run Code Online (Sandbox Code Playgroud)

那就像使用它一样

git here
Run Code Online (Sandbox Code Playgroud)

请注意,我添加了--allow-empty选项git commit,这将使其在空目录和包含内容的目录中工作.