.gitconfig에 모든 미해결 파일을 빠르게 추가하고 커밋 한 다음 PR을 푸시 할 수있는 별칭이 있습니다. 아마 어딘가에서 복사했습니다.
[alias]
lazy = "!f() { git add -A && git commit -m \"$@\" && git push; }; f"
이렇게하면 다음을 수행 할 수 있습니다.
> git lazy "HS-123: Add logging functionality"
더 게으 르기 위해 현재 브랜치의 이름을 읽고 커밋 주석을 파싱하여 간소화하고 싶습니다. 티켓 작업을 시작할 때 티켓 번호와 기능이 포함 된 지점 이름을 만듭니다. 예를 들어 티켓 HS-123은 로깅 기능을 추가하고 있습니다. 그래서 내 지점은 feature/hs-123-add-logging-functionality
.
브랜치 이름을 구문 분석하여 HS-123: Add logging functionality
. 따라서 티켓 이름과 콜론, 대시가 제거 된 기능 설명입니다. 이런 식으로 입력 git lazy
하고 완료 할 수 있습니다.
다음과 같은 질문이 있습니다.
추신이 답변과 다른 답변 덕분에 앞으로 다른 사람들에게 도움이 될 수있는 대본을 함께 만들었습니다.
[alias]
foo = "!f() { : convert branch name like hotfix/hs-123-add-logging into a comment like HS-123: Add logging; \
: get the current branch; \
branch="$(git branch --show-current)"; \
: find the index of the forward slash; \
index="$(expr index "$branch" /)"; \
: remove everything before the forward slash leaving hs-123-add-logging; \
withoutEnvironment=${branch:$index}; \
: parse out the description only e.g. add-logging; \
description=${withoutEnvironment#*-*-}; \
: parse out the ticket number only e.g. hs-123; \
ticket=${withoutEnvironment%-"$description"}; \
: upper case the first letter of description e.g. Add-logging; \
description=${description^}; \
: replace dashes with spaces e.g. Add logging; \
description=${description//-/ }; \
: upper case the entire ticket number e.g. HS-123; \
ticket=${ticket^^}; \
separator=': '; \
: create a comment by combining ticket, separator and description; \
comment=${ticket}${separator}${description}; \
: git add, commit and push; \
git add -A && git commit -m \"${comment}\" && git push; \
}; f"
예, 별칭은 shell입니다. 힘내를 발동 /bin/sh
하고, dash
데비안과 우분투,하지에 bash
. 따라서 데비안이 정책 매뉴얼에 문서화 한 추가 기능을 추가하여 POSIX 셸 의미 체계로 제한해야합니다 local
. Git은로 시작하는 모든 별칭 !
을 셸로 보냅니다 .
브랜치 이름을 얻으려면 git rev-parse --abbrev-ref HEAD
. 이것은 스크립트에서 git branch
사용되는 것이 아니기 때문에 스크립팅에 더 좋습니다 .
커밋 메시지를 작성하는 것이 목표라면 메시지 편집 코드를 commit-msg
후크에 넣고 텍스트를 본격적인 쉘 스크립트 (또는 다른 언어로 된 스크립트)로 처리하는 것이 좋습니다. 한 줄로만 구성된 커밋 메시지를 작성하는 것은 좋은 생각이 아니므로 실제로 편집기에서 추가 텍스트를 작성하고 싶을 것입니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다