[英]git add commit push one liner for powershell windows
我正在寻找一个命令,我可以使用新的Powershell为 Windows add
commit
和push
。
像lazygit my commit msg
//如果可能的话,我更喜欢不带引号
我查看了一些关于 SO 的问题,例如git 添加、提交和推送命令合二为一? 它提供了解决方案,但针对bash
:
function lazygit() {
git add .
git commit -a -m "$*"
git push
}
//use it like lazygit my commit msg
Another answer suggested a git alias: git config --global alias.lazy ';f() { git add -A && git commit -m "$@" && git push; }; f'
git config --global alias.lazy ';f() { git add -A && git commit -m "$@" && git push; }; f'
但我必须在提交消息中添加引号并且不能使用空格(给出错误error: pathspec 'commit message' did not match any file(s) known to git
)
当然,有一种解决方案可以在一行中使用;
编写多个命令。 但我希望简单的一个词命令
这个 function 对你有用吗?
function lazygit {
param(
[Parameter(ValueFromRemainingArguments = $true)]
[String[]] $message
)
git add .
git commit -a -m "$message"
git push
}
运行这个:
lazygit my commit message
将运行这三个命令:
git add .
git commit -a -m "my commit message"
git push
您可以使用以下Powershell命令:
git add .;git commit -m "commit message";git push origin master
通过使用; 为了分隔每个命令,它们可以一次键入并按顺序运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.