2011-11-23 4 views
0

GitPython 라이브러리에서 로컬 변경 사항을 단일 파일로 되 돌리는 방법이 있습니까? 난 그냥 git checkout filename를 사용하지만 GitPython의 API에서이 작업을 수행하려고 시도하는 것 망할 놈의 명령 줄에서GItPython을 사용하여 로컬 변경 사항을 파일로 되 돌리십시오.

, 그래서

repo.index.checkout([filename]) 

다음과 같은 오류에 이르게처럼

git.exc.CheckoutError: Some files could not be checked out from the index due to local modifications:['foo']

답변

0

아, 생각 게시 후 몇 분 후에 source을 보시면됩니다.

repo.index.checkout([filename]. force=True)을 사용하여 강제로 켜면 제대로 작동합니다.

더 좋은 방법이있을 수 있지만 소스에 따라 강제 변경 매개 변수가 로컬 변경 사항을 덮어 씁니다.

:param force:
If True, existing files will be overwritten even if they contain local modifications.
If False, these will trigger a CheckoutError.

관련 문제