와.. 무슨 한글로 썼는데 다 영어네...
https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files
Q . How do I force “git pull” to overwrite local files?
Q. 'git pull' 커맨드로 로컬 디렉토리에 존재하는 파일을 덮어 쓸 수 있나요??
How do I force an overwrite of local files on a git pull
?
로컬 파일 에 존재하는 것을 git pull
로 어떻게 덮어 쓸 수 있나요??
The scenario is the following:
error: Untracked working tree file 'public/images/icon.gif' would be overwritten by merge
How do I force Git to overwrite them?
깃이 파일을 덮어 쓰도록 어떻게 하나요?
The person is a designer - usually,
대부분의 문제는 디자이너에게 발생했습니다.
I resolve all the conflicts by hand, so the server has the most recent version that they just need to update on their computer.
그리고 제가 모든 에러들을 해결한 후 서버에 최신 버전을 업데이트 해서 다른 팀원들은 자신의 로컬 파일만 업데이트 하면 됩니다.
중요 : 로컬 디렉토리에서 변경사항이 생긴다면, 모두 사라집니다.
--hard
option, any local commits that haven't been pushed will be lost.[*]--hard
옵션 없을 경우엔 push된 로컬 커밋들은 삭제 됩니다.
If you have any files that are not tracked by Git (e.g. uploaded user content), these files will not be affected.
깃이 트래킹 하지 않는 파일이 있다면, 이것 들은 영향을 받지 않습니다.
First, run a fetch to update all origin/
refs to latest:
첫째, origin/
를 업데이트 하기 위해 fetch 합니다.
git fetch --all
Backup your current branch:
자신의 현재 브랜치를 백업 합니다.
git checkout -b backup-master
Then, you have two options:
그 다음엔 두 가지 옵션이 존재합니다.
git reset --hard origin/master
OR If you are on some other branch:
마스터 브랜치에 있는 경우가 아니면.
git reset --hard origin/<branch_name>
git fetch
downloads the latest from remote without trying to merge or rebase anything.
git fetch
는 리모트 디렉토리에서 가장 최근 버전을 merge나 rebase 하지 않고 다운로드 합니다.
Then the git reset
resets the master branch to what you just fetched.
git reset
은 금방 fetch 한 버전과 같게(?) 마스터 브랜치를 리셋합니다.
The --hard
option changes all the files in your working tree to match the files in origin/master
--hard
옵션은 본인의 working tree 에 존재하는 파일들을 origin/master
와 동일하게 변경 시킵니다.
[*]: It's worth noting that it is possible to maintain current local commits by creating a branch from master
before resetting:
master
브랜치를 리셋하기 전에 브랜치를 생성해서 현재의 로컬 커밋들을 유지 할 수 있습니다.
git checkout master
git branch new-branch-to-save-current-commits
git fetch --all
git reset --hard origin/master
After this, all of the old commits will be kept in new-branch-to-save-current-commits
.
실행한 후엔, 모든 커밋들은 new-branch-to-save-current-commits
브랜치에 존재합니다.
Uncommitted changes, however (even staged), will be lost.
커밋 되지 않은 것들, 심지어 스테이징 된 것이여도 사라집니다.
Make sure to stash and commit anything you need.
꼭 stash 하고 커밋 하길 바랍니다.
For that you can run the following:
git stash
And then to reapply these uncommitted changes:
git stash pop