현재 Git에서 체크 아웃 된 커밋 찾기
git bisect
세션 중간에 있습니다.
현재 어떤 커밋 (SHA1 해시)을 찾는 명령은 무엇입니까? git status
이것을 제공하지 않습니다.
편집 : 전화를 걸고 git log
첫 번째 작품이 작동 하는 것 같아요 ?
git bisect
세션 중에 현재 작업 복사본에 체크 아웃 한 커밋을 보는 5 가지 방법이 있습니다 ( 옵션 1-4는 bisect를 수행하지 않을 때도 작동 함 ).
git show
.git log -1
.- 배쉬 프롬프트.
git status
.git bisect visualize
.
아래에서 각 옵션에 대해 자세히 설명하겠습니다.
옵션 1 : git show
현재 체크 아웃 한 커밋을 결정하는 방법에 대한 일반적인 질문에 대한 이 답변 에서 설명했듯이 (출력 중뿐만 아니라 git bisect
) 패치 출력을 억제 git show
하는 -s
옵션 과 함께 사용할 수 있습니다 .
$ git show --oneline -s
a9874fd Merge branch 'epic-feature'
옵션 2 : 자식 로그 -1
git log -1
현재 진행중인 커밋을 찾기 만하면 됩니다.
$ git log -1 --oneline
c1abcde Add feature-003
옵션 3 : 배쉬 프롬프트
Git 버전 1.8.3 이상 (또는 이전 버전 이었습니까?)에서 Bash 프롬프트가 작업 복사본에 체크 아웃 한 현재 분기를 표시하도록 구성되어 있으면 확인한 현재 커밋도 표시됩니다 이등분 세션 중 또는 "분리 된 HEAD"상태에있을 때 아래 예에서 현재 c1abcde
체크 아웃했습니다.
# Prompt during a bisect
user ~ (c1abcde...)|BISECTING $
# Prompt at detached HEAD state
user ~ (c1abcde...) $
옵션 4 : 자식 상태
또한 Git 버전 1.8.3 이상에서 (그리고 이전에는 다시 확실하지 않을 git status
수도 있음 ) running 은 bisect 동안 및 HEAD 상태가 분리 된 상태에서 체크 아웃 한 커밋을 보여줍니다.
$ git status
# HEAD detached at c1abcde <== RIGHT HERE
옵션 5 : 자식 이등분 시각화
마지막으로을 수행하는 동안 또는 내장 별칭 을 git bisect
사용하여 간단하게 시작할 수 있으므로 현재 어느 커밋이 있는지와 지금까지 나쁘고 좋은 것으로 표시 한 커밋을 그래픽으로 볼 수 있습니다. 나는 이것이 1.8.3 버전 이전에 존재했다고 확신한다. 어떤 버전이 도입되었는지는 확실하지 않다.git bisect visualize
git bisect view
gitk
git bisect visualize
git bisect view # shorter, means same thing
당신은 할 수 있습니다 :
git rev-parse HEAD
To explain a bit further: git rev-parse
is git's basic command for interpreting any of the exotic ways that you can specify the name of a commit and HEAD
is a reference to your current commit or branch. (In a git bisect
session, it points directly to a commit ("detached HEAD") rather than a branch.)
Alternatively (and easier to remember) would be to just do:
git show
... which defaults to showing the commit that HEAD
points to. For a more concise version, you can do:
$ git show --oneline -s
c0235b7 Autorotate uploaded images based on EXIF orientation
$ git rev-parse HEAD 273cf91b4057366a560b9ddcee8fe58d4c21e6cb
Update:
Alternatively (if you have tags):
(Good for naming a version, not very good for passing back to git.)
$ git describe v0.1.49-localhost-ag-1-g273cf91
Or (as Mark suggested, listing here for completeness):
$ git show --oneline -s c0235b7 Autorotate uploaded images based on EXIF orientation
If you want to extract just a simple piece of information, you can get that using git show
with the --format=<string>
option...and ask it not to give you the diff with --no-patch
. This means you can get a printf-style output of whatever you want, which might often be a single field.
For instance, to get just the shortened hash (%h
) you could say:
$ git show --format="%h" --no-patch
4b703eb
If you're looking to save that into an environment variable in bash (a likely thing for people to want to do) you can use the $()
syntax:
$ GIT_COMMIT="$(git show --format="%h" --no-patch)"
$ echo $GIT_COMMIT
4b703eb
The full list of what you can do is in git show --help
. But here's an abbreviated list of properties that might be useful:
%H
commit hash%h
abbreviated commit hash%T
tree hash%t
abbreviated tree hash%P
parent hashes%p
abbreviated parent hashes%an
저자 이름%ae
저자 이메일%at
작성자 날짜, UNIX 타임 스탬프%aI
작성자 날짜, 엄격한 ISO 8601 형식%cn
커미터 이름%ce
커미터 이메일%ct
커미터 날짜, UNIX 타임 스탬프%cI
커미터 날짜, 엄격한 ISO 8601 형식%s
제목%f
파일 이름에 적합한 위생 처리 된 제목 줄%gD
reflog 선택기, 예 : refs / stash @ {1}%gd
단축 된 reflog 선택기 (예 : stash @ {1}
사용 git show
인수를 지정하지 않을 때 메시지를 커밋도 보여, 현재의 디폴트는 커밋.
참고 URL : https://stackoverflow.com/questions/11168141/find-which-commit-is-currently-checked-out-in-git
'programing tip' 카테고리의 다른 글
콘센트를 반복 콘텐츠 iOS에 연결할 수 없습니다 (0) | 2020.06.24 |
---|---|
단락 논리 연산자가 필수입니까? (0) | 2020.06.24 |
Go로 시작하는 기능이 없습니까? (0) | 2020.06.24 |
c # /. net에서 예외를 문서화하는 방법 (0) | 2020.06.24 |
여기서 XPath contains ()를 사용하는 방법은 무엇입니까? (0) | 2020.06.24 |