git 1.7.1과 함께 cygwin에서 bash 버전 4.1.2 (1) -release (x86_64-redhat-linux-gnu)를 사용하고 있습니다. 입력 인수를 두 번 사용해야하는 명령의 별칭을 만들고 싶었습니다. 다음은 이러한 지침 , 내가 쓴
[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
한 가지 해결책은 전체 명령을 "
다음 과 같이 입력하는 것입니다 .
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] 삭제
몇 마디 만하겠습니다