git 1.7.1を使用してcygwinでbashバージョン4.1.2(1)-リリース(x86_64-redhat-linux-gnu)を使用しています。input引数を2回使用する必要があるコマンドのエイリアスを作成したかったのです。以下の手順に従って、私が書きました
[alias]
branch-excise = !sh -c 'git branch -D $1; git push origin --delete $1' --
そして私はこのエラーを受け取ります:
$> git branch-excise my-branch
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
最後にa-
とaの両方を試しました--
が、同じエラーが発生します。どうすればこれを修正できますか?
man git-config
言う:
構文はかなり柔軟で寛容です。空白はほとんど無視されます。#と; 文字は行末までコメントを開始し、空白行は無視されます。
そう:
branch-excise = !bash -c 'git branch -D $1; git push origin --delete $1'
と同等です:
#!/usr/bin/env bash
bash -c 'git branch -D $1
上記のスクリプトを実行すると、次のように出力されます。
/tmp/quote.sh: line 3: unexpected EOF while looking for matching `''
/tmp/quote.sh: line 4: syntax error: unexpected end of file
1つの解決策は、コマンド全体を次の場所に配置することです"
。
branch-excise = !"bash -c 'git branch -D $1; git push origin --delete $1'"
ただし、$1
が空であるため、まだ機能しません。
$ git branch-excise master
fatal: branch name required
fatal: --delete doesn't make sense without any refs
それを機能させるには、でダミー関数を作成し、次の.gitconfig
ように呼び出す必要があります。
branch-excise = ! "ddd () { git branch -D $1; git push origin --delete $1; }; ddd"
使用法:
$ git branch-excise master
error: Cannot delete the branch 'master' which you are currently on.
(...)
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加