【发布时间】:2015-11-16 06:15:00
【问题描述】:
git add .; git commit -m 'MESSAGE'; git push origin master
要记住的事情很长...有没有办法可以做到,所以我只需要输入例如gitcommit -'MESSAGE' ?我尝试使用alias,但我不知道如何执行-'MESSAGE' 部分...
附:我在 osx 上,如果相关的话
【问题讨论】:
git add .; git commit -m 'MESSAGE'; git push origin master
要记住的事情很长...有没有办法可以做到,所以我只需要输入例如gitcommit -'MESSAGE' ?我尝试使用alias,但我不知道如何执行-'MESSAGE' 部分...
附:我在 osx 上,如果相关的话
【问题讨论】:
在您的终端上安装 zshell,您将获得 ga 等命令的非常短的别名。对于 git 添加。和 gca -m "message" 用于 git commit 和 ggpush 和 ggpull 用于 git push 和 git pull。这里是安装教程http://sourabhbajaj.com/mac-setup/iTerm/zsh.html
【讨论】:
gitcommit "message" 更短;)
别名不处理参数,但函数处理:
gitcommit () {
# set -e
git add .
git commit -m "$1"
git push origin master
}
我可能会在函数中添加set -e,因为如果添加不成功,您不希望 git 提交。
您可以将函数定义添加到您的 .bashrc 或 .bashprofile 文件中,以便每次启动 shell 时都可以使用它。
【讨论】:
set -e ?
当您在 linux 上时,请编写一个 bash 函数。在一行中完成所有这些。
function gcommit {
git add .
git commit -m "$1"
git push origin master
}
把它放在你的~/.bash_profile 然后你可以使用如下命令:
#gcommit "Your message"
【讨论】: