簡體   English   中英

git 為 powershell windows 添加提交推送一個襯墊

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

我正在尋找一個命令,我可以使用新的Powershell為 Windows add commitpush
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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM