로컬 변경을 무시하면서 힘내? 변경을 무시 하는 방법

git pull디렉토리를 날려 버리지 않고 로컬 파일 변경을 무시 하는 방법 이 git clone있습니까?



답변

풀이 로컬 변경 사항을 덮어 쓰려고하면 작업 트리가 깨끗한 것처럼 병합을 수행하여 작업 트리를 청소하십시오.

git reset --hard
git pull

추적되지 않은 로컬 파일이 있으면이 git clean를 제거하는 데 사용할 수 있습니다. 사용 git clean -f, 비 추적 파일을 제거하는 -df비 추적 파일과 디렉토리를 제거하고, -xdf비 추적 또는 무시 파일이나 디렉토리를 제거 할 수 있습니다.

반면에 로컬 수정 사항을 어떻게 유지하려면 숨김을 사용하여 숨기고 숨기고 나중에 다시 적용하십시오.

git stash
git pull
git stash pop

풀의 절반이 병합되고 커밋 된 버전의 콘텐츠와 가져온 버전을 병합 해야하는 변경 사항 을 문자 그대로 무시 하는 것이 의미가 없다고 생각합니다 .


답변

나를 위해 다음이 효과가있었습니다.

(1) 먼저 모든 변경 사항을 가져옵니다.

$ git fetch --all

(2) 그런 다음 마스터를 재설정하십시오.

$ git reset --hard origin/master

(3) 풀 / 업데이트 :

$ git pull

답변

당신은 정확히 같은 결과를 제공하는 명령을 원합니다 rm -rf local_repo && git clone remote_url. 이 기능도 원합니다. git이 왜 그런 명령을 제공하지 않는지 궁금합니다 (예 : git reclone또는 git sync) svn도 그런 명령을 제공하지 않습니다 (예 : svn recheckout또는 svn sync).

다음 명령을 시도하십시오 :

git reset --hard origin/master
git clean -fxd
git pull

답변

다음 명령은 항상 작동하지 않습니다 . 당신이 그냥하는 경우 :

$ git checkout thebranch
Already on 'thebranch'
Your branch and 'origin/thebranch' have diverged,
and have 23 and 7 different commits each, respectively.

$ git reset --hard
HEAD is now at b05f611 Here the commit message bla, bla

$ git pull
Auto-merging thefile1.c
CONFLICT (content): Merge conflict in thefile1.c
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.

등등…

위해 정말 모든 로컬 변경 사항을 thebranch을 다운로드하고 덮어 쓰기, 시작, 불과 수행


$ git checkout thebranch
$ git reset --hard origin/thebranch

이것은 잘 작동합니다.

$ git checkout thebranch
Already on 'thebranch'
Your branch and 'origin/thebranch' have diverged,
and have 23 and 7 different commits each, respectively.

$ git reset --hard origin/thebranch
HEAD is now at 7639058 Here commit message again...

$ git status
# On branch thebranch
nothing to commit (working directory clean)

$ git checkout thebranch
Already on 'thebranch'

답변

git fetch --all && git reset --hard origin/master

답변

git stash 를 보고 모든 로컬 변경 사항을 “스 태쉬 파일”에 넣고 마지막 커밋으로 되 돌리십시오. 이때 숨김 변경 사항을 적용하거나 버릴 수 있습니다.


답변

Linux를 사용하는 경우 :

git fetch
for file in `git diff origin/master..HEAD --name-only`; do rm -f "$file"; done
git pull

for 루프는 로컬 저장소에서 변경된 모든 추적 파일을 삭제하므로 git pull아무런 문제없이 작동합니다.
이것에 대한 가장 좋은 점은 추적 된 파일 만 repo의 파일로 덮어 쓰이고 다른 모든 파일은 그대로 유지됩니다.