有没有办法同时使用这三个命令呢?
git add .
git commit -a -m "commit" (do not need commit message either)
git push
有时我只更改一个字母,CSS填充或其他什么。尽管如此,我仍然必须编写所有这三个命令来推动更改。在很多项目中,我只是一个推动者,所以这个命令太棒了!
发布于 2014-04-28 05:06:23
基于@Gavin的答案:
将lazygit设置为函数而不是别名允许您向其传递参数。我已经将以下内容添加到我的.bashrc (如果是Mac,则为.bash_profile ):
function lazygit() {
git add .
git commit -a -m "$1"
git push
}
这允许您提供提交消息,例如
lazygit "My commit msg"
当然,您可以通过接受更多的参数来进一步强化这一点,例如推送到哪个远程位置,或者哪个分支。
发布于 2016-01-28 06:48:30
我最终向我的.gitconfig
文件添加了一个别名:
[alias]
cmp = "!f() { git add -A && git commit -m \"$@\" && git push; }; f"
用法:git cmp "Long commit message goes here"
添加所有文件,然后使用提交消息的注释并将其推送到源位置。
我认为这是一个更好的解决方案,因为您可以控制提交消息是什么。
也可以从命令行定义别名,这会将其添加到.gitconfig
中
git config --global alias.cmp '!f() { git add -A && git commit -m "$@" && git push; }; f'
发布于 2016-01-03 03:39:35
我在我的.bash_profile中使用了这个
gitpush() {
git add .
git commit -m "$*"
git push
}
alias gp=gitpush
它的执行方式如下
gp A really long commit message
别忘了在保存别名后运行source ~/.bash_profile
。
https://stackoverflow.com/questions/19595067
复制相似问题