2011-08-05 4 views
55

버전이있는 파일의 여러 행을 수정 한 경우 의 명령 줄을 변경 취소 할 수 있습니까?전체 파일 대신 단일 행을 git-checkout 할 수 있습니까?

내가 가진 모든 파일을 할 것입니다 마찬가지로 :

git checkout /path/to/file.extension 

하지만 같은 일을하고이 가능

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

라고?

답변

85

git checkout -p을 사용하여 각 행크를 개별적으로 확인하고 체크 아웃할지 또는 그대로 둘지 결정할 수 있습니다. 추가로 범위를 좁히려면 선택적인 경로 인수도 사용합니다. 매트의 대답에 정교하게

24

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 

ynse 옵션

시작하기에 좋은 장소입니다.

은 참조 :

관련 문제