Program Club

전체 파일 대신 한 줄을 git-checkout 할 수 있습니까?

proclub 2020. 10. 18. 19:51
반응형

전체 파일 대신 한 줄을 git-checkout 할 수 있습니까?


버전이 지정된 파일의 여러 줄을 수정 한 경우 명령 줄로 의 변경 사항을 취소 할 수 있습니까?

다음을 사용하여 전체 파일에 대해 수행하는 것과 같습니다.

git checkout /path/to/file.extension

하지만 이렇게 말하면

git checkout /path/to/file.extension --line 10

이것이 가능한가?


을 사용 git checkout -p하여 각 덩어리를 개별적으로보고 체크 아웃할지 또는 그대로 둘지 결정할 수 있습니다 (더 좁히려면 선택적 경로 인수도 사용함 ).


Matt의 답변에 대해 자세히 설명하려면 git checkout --patch -- <path argument>다음 옵션을 사용하여 대화 형 모드를 시작합니다.

y - stage this hunk
n - do not stage this hunk

q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk

s - split the current hunk into smaller hunks
e - manually edit the current hunk

? - print help

y n se옵션은 시작하기에 좋은 장소입니다.

또한보십시오:

참고 URL : https://stackoverflow.com/questions/6963129/is-it-possible-to-git-checkout-a-single-line-instead-of-the-entire-file

반응형