有什么方法可以同时使用这三个命令吗?

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

有时我只改变一个字母,CSS填充之类的。不过,我必须编写所有三个命令来推动更改。有许多项目,我只是一个推动者,所以这个命令将是了不起的!


当前回答

正如回答中提到的,您可以创建一个git别名并为其分配一组命令。在这种情况下,它将是:

git config --global alias.add-com-push '!git add . && git commit -a -m "commit" && git push'

用在

git add-com-push

其他回答

对于MAC VSC用户来说,最好的设置是:

1)按'shift+cmd+P'并输入:

Shell Command: install 'code' command in PATH

按ENTER(这将安装代码命令,以便轻松获得bash_profile)

2)你现在可以运行:code ~/。打开空的Bash_profile

3)在那里输入一个新函数:

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

4)现在重启VSC

5)进行更改,保存并输入lazygit message同时运行这三个命令

在Linux/Mac中,这个非常实用的选项也可以工作

git commit -am "IssueNumberIAmWorkingOn --hit Enter key
> A detail here --Enter
> Another detail here --Enter
> Third line here" && git push --last Enter and it will be there

如果你正在处理一个本地创建的新分支,使用git push -u origin branch_name来更改git push片段

如果你想在系统编辑器中编辑你的提交信息,那么

git commit -a && git push 

将打开编辑器,一旦你保存消息,它也会推送它。

macOS用户:

打开您的终端或iTerm2或您使用的其他终端。 使用~/命令移动到用户配置文件文件夹。它是.bash_profile文件的默认文件夹:

输入nano. bash_profile这个命令将在最容易使用的终端nano文本编辑器中打开.bash_profile文档(如果它还不存在,也可以创建它)。 现在您可以对文件进行简单的更改。粘贴以下代码行来更改终端提示符:

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

现在通过输入ctrl + o保存您的更改,并点击返回保存。然后输入ctrl + x退出nano。 现在我们需要激活您的更改。输入source .bash_profile(或。~/.bash_profile)并注意提示符的变化。 在iTerm2的Preferences/Profiles/General/Command中设置为Login Shell并在start时发送文本到source ~/.bash_profile。因此,您不需要在每次macOS重新启动后手动进行设置。

凭证:https://natelandau.com/my-mac-osx-bash_profile

如果你用的是Mac电脑:

打开终端,输入cd ~/进入主文件夹 输入touch .bash_profile创建新文件。 使用您最喜欢的编辑器编辑.bash_profile(或者您可以直接键入 open -e .bash_profile在TextEdit中打开它)。 复制并粘贴下面的文件:

函数lazygit() { Git添加。 Git commit -m "$1" git推 }

在这之后,重启你的终端,简单地添加,提交和推送一个简单的命令,例如:

lazygit "This is my commit message"

正如回答中提到的,您可以创建一个git别名并为其分配一组命令。在这种情况下,它将是:

git config --global alias.add-com-push '!git add . && git commit -a -m "commit" && git push'

用在

git add-com-push