简体   繁体   English

git 为 powershell windows 添加提交推送一个衬垫

[英]git add commit push one liner for powershell windows

I am looking for a single command where I can add commit & push using new Powershell for Windows.我正在寻找一个命令,我可以使用新的Powershell为 Windows add commitpush
Single command like lazygit my commit msg // I'd prefer w/o quotes if possiblelazygit my commit msg //如果可能的话,我更喜欢不带引号

I looked over few questions on SO like git add, commit and push commands in one?我查看了一些关于 SO 的问题,例如git 添加、提交和推送命令合二为一? which provided solution but for bash :它提供了解决方案,但针对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' 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'

but i have to add quotes and can't use spaces in commit message (gives error error: pathspec 'commit message' did not match any file(s) known to git )但我必须在提交消息中添加引号并且不能使用空格(给出错误error: pathspec 'commit message' did not match any file(s) known to git


ofcourse, there's one solution to write multiple commands in one line using ;当然,有一种解决方案可以在一行中使用;编写多个命令。 but I'm hoping for simple one word command但我希望简单的一个词命令

Does this function work for you?这个 function 对你有用吗?

function lazygit {
  param(
    [Parameter(ValueFromRemainingArguments = $true)]
    [String[]] $message
  )
  git add .
  git commit -a -m "$message"
  git push
}

Running this:运行这个:

lazygit my commit message

Will run these three commands:将运行这三个命令:

git add .
git commit -a -m "my commit message"
git push

You can use the following Powershell command:您可以使用以下Powershell命令:

git add .;git commit -m "commit message";git push origin master

By using;通过使用; to separate each command, they can be typed at once and run sequentially.为了分隔每个命令,它们可以一次键入并按顺序运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM