git添加,提交和推送命令在一个? [英] git add, commit and push commands in one?

查看:431
本文介绍了git添加,提交和推送命令在一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  git add。有没有办法在一个中使用这三个命令? 
git commit -a -mcommit(不需要提交消息)
git push

有时我只更改一个字母,CSS填充或其他内容。不过,我必须编写所有三个命令来推送更改。有很多项目,我只有一个推动者,所以这个命令会很棒!

解决方案

制作@ Gavin的答案:

制作lazygit a函数而不是别名允许你传递一个参数。我已经将以下内容添加到我的.bashrc(或Mac上的.bash_profile)中:

  function lazygit(){
git add。
git commit -a -m$ 1
git push
}

这允许您提供一个提交消息,比如

  lazygitMy commit msg

code>

当然,您可以通过接受更多参数来进一步提高这个参数,例如推送哪个远程位置或哪个分支。

Is there any way to use these three commands in one?

git add .
git commit -a -m "commit" (do not need commit message either)
git push

Sometimes I'm changing only one letter, CSS padding or something. Still, I have to write all three commands to push the changes. There are many projects where I'm only one pusher, so this command would be awesome!

解决方案

Building off of @Gavin's answer:

Making lazygit a function instead of an alias allows you to pass it an argument. I have added the following to my .bashrc (or .bash_profile if Mac):

function lazygit() {
    git add .
    git commit -a -m "$1"
    git push
}

This allows you to provide a commit message, such as

lazygit "My commit msg"

You could of course beef this up even more by accepting even more arguments, such as which remote place to push to, or which branch.

这篇关于git添加,提交和推送命令在一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆