programing tip

Git-파일을 추가하지 않습니까?

itbloger 2020. 11. 16. 07:54
반응형

Git-파일을 추가하지 않습니까?


내 저장소에 파일을 추가 할 수없는 문제가 있습니다.

일부 Ruby 개발을 위해 Aptana Studio의 Windows에서 GIT를 사용하고 있습니다.

몇 개의 파일을 GitHub로 푸시했지만 그 후 모든 것이 작동을 멈췄습니다. 예를 들어 마스터 디렉토리에 2 개의 루비 파일이있는 새 하위 폴더가 있습니다. 내가 "git add."를 호출 한 다음 "git status"를 호출하면 "working directory clean"이 계속 표시되고 커밋 할 항목이 없습니다.

"git add folder / myfile.rb"를 시도했지만 여전히 아무것도 없습니다.

누구든지 내가 시도 할 수있는 아이디어가 있습니까?


나는 포스터와 비슷한 상황에 처해 있었다.

내가 "git add."를 호출 한 다음 "git status"를 호출하면 "working directory clean"이 계속 표시되고 커밋 할 항목이 없습니다.

하지만 여기에있는 것과는 다른 해결책이있었습니다. 처음 왔기 때문에 다른 사람들에게 시간을 절약하고 싶습니다.

위의 답변과 다른 곳에서 본 것에서이 문제에 대한 일반적인 수정 사항은 다음과 같습니다.

  • 해당 파일에 실제로 저장된 변경 사항이 있는지 확인
  • 파일이 .gitignore의 제외 규칙을 충족하지 않는지 확인하십시오..git/info/exclude
  • 빈 폴더를 추가하지 않도록하십시오. Git은 그것들을 추적하지 않습니다. 표준 솔루션은 .gitkeep자리 표시 자로 명명 된 빈 파일을 배치하여 git이 폴더를 추적하도록하는 것입니다.

제 경우에는 원래 기존 리포지토리 주변에 git 리포지토리를 만들려고했습니다. .git얼마 전에이 하위 저장소에서 폴더를 제거 했지만 너무 늦었다는 사실을 몰랐고 git은 이미 하위 모듈 로 추적하고있었습니다 . 여기 에서 이러한 기능과 제거 방법에 대해 자세히 알아볼 수 있지만

  • 나를위한 해결책은 단순히 실행하는 것이 었습니다 git rm --cached path_to_submodule.

다른 사용자를 위해 가능한 솔루션을 추가하려면 :

Windows에서 폴더 이름의 대소 문자를 변경하지 않았는지 확인하십시오.

SetupGit에 의해 제어되고 GitHub에서 호스팅되는 폴더 가 Windows 시스템에서 수행 되는 유사한 문제가 발생 했습니다.

어느 시점에서 폴더를 setup(소문자 S) 로 변경했습니다 . 그 시점부터 새 파일을 설치 폴더에 추가했을 때 폴더가 setup아닌 폴더에 저장 Setup되었지만 Windows 시스템에서 개발 중이었기 때문에 Setupgit / github 의 기존 폴더가 setup.

그 결과 setupGitHub 에서 모든 파일을 볼 수 없었습니다 . 나는 내가 * nix에서 스크립트 시스템에서 프로젝트를 복제하면 나는 두 개의 폴더를 본 것이라고 의심 Setup하고 setup.

따라서 Windows 컴퓨터에서 포함하는 폴더의 대소 문자를 변경하지 않았는지 확인하십시오.

  • 폴더 이름을 다음과 같이 변경 setup-temp
  • git add -A
  • git commit -m "Whatever"
  • 폴더 이름을 원하는 이름으로 다시 변경하십시오.
  • git add -A
  • git commit -m "Whatever"

파일이에서 제외되고 .gitignore어쨌든 추가하려는 경우 다음을 사용하여 강제 할 수 있습니다.

git add -f path/to/file.ext

더블은 확인 .gitignore해야합니다 파일이 망할 놈 볼 수 할 수 있는지 확인하기 위해 파일을. 마찬가지로 파일 .git/info/exclude마찬가지로 프로젝트에서 파일 / 디렉토리를 '제외'하는 .gitignore파일이 있습니다.


이상하지만 밤새도록 파일을 추가하기 위해 자식과 싸웠습니다. 이미 추가 된 것으로 밝혀졌습니다. 내 계정에서 파일에 액세스 할 수없고 내 IDE가 SSH를 통해이를보고하지 않았기 때문에 변경 사항이 저장되지 않았기 때문에 Git이 내 변경 사항을 선택하지 않았습니다.

요컨대, 저장소에 이미 추가되지 않았는지 확인하십시오.


가장 좋은 방법은 폴더를 복사하는 것입니다. 원본을 삭제하십시오. github에서 프로젝트를 복제하고 새 파일을 복제 된 새 폴더에 복사 한 다음 다시 시도하십시오.


나는 방금이 문제가 있었고 문제는 내가 최상위 수준이 아닌 디렉토리 안에 있다는 것입니다. 최상위 수준으로 이동하면 작동했습니다.


폴더의 첫 번째 프로그램에서이 문제가 발생했습니다. 나는 "git add"다음 "git commit"을했다. "git status"는 "커밋 할 항목 없음, 작업 디렉토리 정리"오류를 설명했습니다.

프로그램 폴더에서 .git 파일을 삭제했습니다. 그런 다음 새로운 git init, git add 및 git commit을 수행했으며 작동했습니다.


표준 절차는 어떻습니까?

git add folder
git commit

이렇게하면 단일 명령으로 폴더와 모든 파일이 추가됩니다.
git은 빈 폴더를 저장할 수 없습니다.

커밋이 작동하지 않으면 확인해야 할 첫 번째 장소는 아마도 .gitignore.


여기 에서 동일한 문제에 대한 답을 찾을 수 있습니다.

basically in this case the problem was the global_git ignore


In my case the issue was enabled SafeCrLf option. I am on windows with tortoise git. After disabling the option adding the files was not an issue anymore.


Silly solution from me, but I thought that it wasn't adding and pushing new files because github.com wasn't showing the files I had just pushed. I had forgotten that the files I added were on a different branch. The files had push just fine. I had to switch from my master branch to the new branch in github to see them. Lost a few minutes on that one :)


Another issue can be file permissions. Try issuing : chmod 755 file1


It's impossible (for me) to add the first file to an empty repository cloned from GitHub. You need to follow the link README, that GitHub suggests to create. After you create your first file online, you can work normally with git.

This happened to me Nov 17, 2016.


I searched around for a while and ended up finding out I had blocked off the SSH port which was what caused the git add command to stop working. I ended up changing origin using https with the following command: git remote set-url origin [url-to-git-repo]


I know this is a really old question, but I know it can happen to someone as well, turns out I was working with a file named AUX.JS and thi is a reserved file name for windows, this produced the following error

fatal: unable to stat 'src/hoc/Aux.js': No such file or directory

so you can either remove the file or rename it, then it will work.

Final conclusion, in addition to all other valid answers, if you are in a windows machine look out for the output of the 'git add' command, it can also provide additional information.


Had the same issue with a repo that I cloned from SiteGround Git to my mac. The freshly cloned repo had a list of changed files that git status said needed to be added to the commit, but trying to add or checkout any of them didn't do anything at all.

For some reason there were case changes in the filenames (e.g. .jpg -> .JPG). The solution was to simply git mv the filename the OS was using to the name git was using, e.g.:

git mv File_That_Wont_Add.txt File_THAT_WONT_Add.txt

I recently experienced this issue on my computer running Windows 7. I am using the git command window interface. The solution was to be very careful about the case sensitivity of the file and directory names when doing the git add. Although git would not complain when the case did not exactly match the case of the Windows file system file and directory names it also would not add the files. There would be nothing to commit. Once I typed the file names with the exactly correct case they would be added and listed under the changes to be committed as I intended.


I was having this issue on Visual Studio, what worked for me was: 1- Right click on the added file that is not being recognized by git. 2- Select "Add excluded file to Source Control"


I had the same problem and it was because there was a program using some file and git throws an error in this case Visual Studio had locked that file.

참고URL : https://stackoverflow.com/questions/7490798/git-wont-add-files

반응형