Git은 파일 재설정 / 삭제를 거부합니다.
업데이트 할 수없는 특정 js 파일이있는 프로젝트가 있습니다. OSX를 로컬에서 실행하고 원격 / 스테이징 서버는 Linux (CentOS)입니다.
내 프로젝트를 로컬로 복제 한 직후 git status 인 모든 파일이 있음을 알았습니다 modified
. 나는 그것들을 수정하지 않았기 때문에 discard changes
또는 reset
그것들을 시도 했지만 그들은 다시 나타납니다. 수정 된 변경 사항은 모든 줄을 삭제하고 다시 추가하는 것입니다.
왜 이런 일이 발생하는지 또는 내 자식 상태가 필요에 따라 깨끗하도록 수정하는 방법을 모르겠습니다.
다음은 git 상태의 몇 줄입니다.
# modified: app/webroot/js/ckeditor/plugins/devtools/lang/el.js
# modified: app/webroot/js/ckeditor/plugins/devtools/lang/fa.js
# modified: app/webroot/js/ckeditor/plugins/devtools/lang/gu.js
업데이트 1 :
이제 위의 파일을 커밋했지만 새 편집을 가져 오지 않기 때문에 스테이징 서버가 잠겨 있습니다.
error: Your local changes to the following files would be overwritten by merge:
app/webroot/js/ckeditor/_source/lang/ar.js
app/webroot/js/ckeditor/_source/lang/bg.js
app/webroot/js/ckeditor/_source/lang/bn.js
app/webroot/js/ckeditor/_source/lang/cs.js
...
Aborting
다음과 같은 이유로 커밋 / 푸시 할 수 없습니다.
Updates were rejected because a pushed branch tip is behind its remote counterpart
나는 시도했다 :
git reset --hard
과
git stash
git stash drop
하지만 작동하지 않고 아무 일도 일어나지 않습니다.
업데이트 2 :
git diff
나에게 준다 :
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in app/webroot/js/ckeditor/_source/lang/fa.js.
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in app/webroot/js/ckeditor/_source/lang/gu.js.
The file will have its original line endings in your working directory.
...
줄 끝 정규화
수정 된 변경 사항은 모든 줄을 삭제하고 다시 추가하는 것입니다.
이는 커밋 된 파일과 디스크의 파일간에 줄 바꿈이 변경되기 때문입니다.
Github에는 이러한 종류의 문제를 간단히 처리하는 방법을 자세히 설명하는 편리한 페이지 가 있습니다 (리눅스 / OSX의 경우), 첫 번째 단계는 git 구성을 변경하여 줄 끝을 정렬하는 것입니다.
git config --global core.autocrlf input
그런 다음 줄 끝 정규화를 커밋합니다.
git rm --cached -r .
# Remove everything from the index.
git reset --hard
# Write both the index and working directory from git's database.
git add .
# Prepare to make a commit by staging all the files that will get normalized.
# This is your chance to inspect which files were never normalized. You should
# get lots of messages like: "warning: CRLF will be replaced by LF in file."
git commit -m "Normalize line endings"
# Commit
그런 다음 줄 끝이 올바르게 처리되어야합니다. 자세한 내용은 github의 도움말 페이지 또는 git docs 형식 지정 및 공백 관련 섹션을 참조하십시오 .
리눅스-머신 충돌 해결
스테이징 서버는 새로운 편집을 가져 오지 않기 때문에 잠겨 있습니다.
오류 메시지는 "다음 파일에 대한 로컬 변경 사항은 병합으로 덮어 쓰여집니다."라는 메시지가 표시됩니다. 이는 계속하기 전에 커밋하거나 삭제해야하는 로컬 변경 사항이 포함되어 있음을 의미합니다. 스테이징 서버의 정상적인 사용을 가정하면 (의도적 인 변경 사항이 없음) 로컬 변경 사항을 삭제할 수 있습니다. 예를 들어 다음을 수행하십시오.
$ git fetch origin
# Retrieve updates
$ git reset --hard origin/master
# Forcibly change the current branch to match origin/master
이렇게하면 작업 복사본을 업데이트하지 않고 저장소 기록을 검색 한 다음 저장소의 마스터 분기와 정확히 일치하도록 업데이트합니다. 마지막 명령은 커밋되지 않은 모든 변경 사항을 무시합니다.
나는 " Git : stuck repo using stash after crlf normalization? " 에서와 같이로 core.autocrlf
설정 되어 있는지 항상 확인했습니다 .false
git config --global core.autocrlf false
Also make sure that you don't have a .gitattributes
file with eol
directives that would try to convert the end-of-lines.
The basic idea is: do you still see that error message when you make sure there is no automatic conversion of any sort?
But just in case, consider also "Git rebase fails, 'Your local changes to the following files would be overwritten by merge'. No local changes?"
I'm on a mac, and this obscure config change seemed to fix all my woes regarding unstaged changes when there were none.
git config --global core.trustctime false
I just spent 2 hours (!) on the same issue with a .svg file (Scalar Vector Graphics), which kept changing after 'revert' without my intervention.
So the file shows up as modified in 'git status'; reverting it succeeds, but it keeps changing, so the 'pull' is failing again and again.... so annoying!
No luck with 'git reset', 'git ignore', 'git untrack' etc...
Finally, I solved it by removing the file from my local system (not 'git delete', just Shift + Delete) >> now 'pull' request passes, and the file is fetched from the remote repository.
So easy, I could cry!
This issue repeatedly popped up with the Roll20 character sheets repository on an Ubuntu machine and I could solve it by
#!/bin/sh
# Use in root dir of git repository
# Fixes some newline-related weirdness
git rm --cached -r .
git reset --hard
But, this stopped resolving the issue completely today and by looking around Stack Overflow I found the culprit to be their .gitattributes
file:
# Auto detect text files and perform LF normalization
* text=auto
After git pull origin master
, git status
returned:
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Star Wars Revised RPG/SWRRPG-updated.html
no changes added to commit (use "git add" and/or "git commit -a")
The solution was to remove the * text=auto
line from the .gitattributes:
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .gitattributes
no changes added to commit (use "git add" and/or "git commit -a")
The changes on .gitattributes
can be discarded and Git will still be satisfied.
Edit +1d: Retried the .gitattributes "trick" today, but did not git status
before discarding the .gitattributes changes. For no reason obvious to me (maybe caching of git status
?), a git status
afterwards returned this again:
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Star Wars Revised RPG/SWRRPG-updated.html
no changes added to commit (use "git add" and/or "git commit -a")
Doing it again, but with git status
inbetween worked.
참고URL : https://stackoverflow.com/questions/18536863/git-refuses-to-reset-discard-files
'code' 카테고리의 다른 글
Android int를 String으로 변환하는 방법은 무엇입니까? (0) | 2020.10.20 |
---|---|
JavaScript에서 ISO 날짜를 날짜 형식 yyyy-mm-dd로 변환 (0) | 2020.10.20 |
Python : os.system을 실행 한 후 stdout을 얻는 방법? (0) | 2020.10.19 |
Spring Boot application.properties 값이 채워지지 않음 (0) | 2020.10.19 |
(…) 쿼리에서 HQL을 작성하는 적절한 방법 (0) | 2020.10.19 |