Nice programing

git add -A는 디렉토리의 모든 수정 된 파일을 추가하지 않습니다.

nicepro 2020. 12. 12. 12:25
반응형

git add -A는 디렉토리의 모든 수정 된 파일을 추가하지 않습니다.


삭제, 생성, 수정, 추적 해제 여부와 관계없이 모든 파일을 추가하고 싶습니다. 난 그냥 추가 GIT하고 싶지 않은 모든 내 파일 마다 . 시도 git add -A했지만 폴더 안에 수정 된 파일을 추가 하지 않습니다 .

git status내 프로젝트의 이니셜은 다음과 같습니다 .

Rakib-MacBook-Pro:my-xcode-practice rakib$ git status
# On branch 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)
#   (commit or discard the untracked or modified content in submodules)
#
#   modified:   BankAccount (modified content, untracked content)
#   modified:   BuckysButtons (modified content, untracked content)
#   modified:   multiview (modified content, untracked content)
#   modified:   rotator (modified content, untracked content)
#   modified:   segmentedControls (modified content, untracked content)
#
no changes added to commit (use "git add" and/or "git commit -a")

그런 다음 다음을 넣습니다 git add -A.

Rakib-MacBook-Pro:my-xcode-practice rakib$ git add -A

다음 여기에 새로운 상태입니다 AFTER 하고는 git add -A:

Rakib-MacBook-Pro:my-xcode-practice rakib$ git status
# On branch 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)
#   (commit or discard the untracked or modified content in submodules)
#
#   modified:   BankAccount (modified content, untracked content)
#   modified:   BuckysButtons (modified content, untracked content)
#   modified:   multiview (modified content, untracked content)
#   modified:   rotator (modified content, untracked content)
#   modified:   segmentedControls (modified content, untracked content)
#
no changes added to commit (use "git add" and/or "git commit -a")

에 변경 사항이 없음을 알 수 있습니다 git status. 이 문제를 어떻게 해결합니까?

나는 또한 시도했다 git add .-그것은 도움이되지 않았다

나는 또한 시도했다 git add *-그것은 도움이되지 않았다


문제는 여기에 그 BankAccount, BuckysButtons, multiview, rotator그리고 segmentedControls여러 가지면에서 독립 저장소처럼 행동 모든 자식 서브 모듈이 있습니다.

원하는 것이 git add -A .각 하위 모듈에서 실행 되는 것이라면 다음을 수행 할 수 있습니다.

git submodule foreach --recursive git add -A .

그런 다음 다음을 사용하여 모든 하위 모듈에서 커밋을 만들 수 있습니다.

git submodule foreach --recursive "git commit -m 'Committing in a submodule'"

(해당 하위 모듈 내에 다른 하위 모듈이 중첩되어 있지 않으면 --recursive옵션이 필요하지 않습니다.)

그러나 나는 이것을 권장하지 않습니다. 차례로 각 하위 모듈을 신중하게 변경하고 업데이트 방법을 고려하여 각각을 독립형 저장소로 취급해야합니다. 그런 다음 프로젝트 전체가 각 하위 모듈의 새 버전에서 작동하는지 테스트 한 경우에만 이러한 새 하위 모듈 버전을 기본 프로젝트에서 커밋합니다.


업데이트 : 아래 주석에서 인용 한 오류 메시지에서 이러한 다른 git 저장소를 하위 모듈이 아닌 직접 추가 한 것으로 보입니다. 당신이 당신의 저장소로 다른 자식 저장소를 복사 한 다음 바로 사용하는 경우에 발생할 수 있습니다 git add오히려 그것을 추가하는 대신, 그것을 무대 git submodule add <REPOSITORY-URL>. 정말로 이것을 서브 모듈로 저장하려는 경우 저장소에서 제거하고 삭제를 커밋 한 다음 하위 모듈로 올바르게 추가하는 것이 좋습니다.git submodule add


우연히 다시 만들었습니다.

다른 폴더에있는 프로젝트를 새 git 저장소에 복사했습니다. 나는 그것을 서브 모듈로 사용하려는 것이 아니라 새 프로젝트의 시작점으로 사용하려고했습니다. 내가 복사 한 프로젝트는 이제 내 메인 git repo의 하위 폴더가 .git/되었습니다. 삭제 subfolder/.git/.

rm -rf subfolder/.git

Then things were still weird...

git status

Nothing to commit. Hmm... What about all of these files?

I didn't really know how to fix this properly with git, so I duplicated the directory, and deleted the original.

cp subfolder newsubfolder    
rm -rf subfolder

Then I added all changed files, committed, and pushed.

git add -A
git commit -am 'i did something and there are now files'
git push origin <branchName>

A pretty simple fix for me - I had opened the Git Bash in a subdirectory of the project.

Open the Bash and doing the commands in the root directory fixed this problem; git add -A . worked as expected.


I solved this by deleting the .git folders inside the supposed submodules and inside the project root, and then doing a new 'git init'


This error occurs because you have added a folder which is already linked with some another github repository .

To solve this issue first copy the files you want to upload to github from the BankAccount folder and then delete the BankAccount folder.

Now make a new folder and then paste the files in it.

It is due to the git submodules that is automatically taken by git present in the earlier folder.

Now you can do

git add . 
git status

Let's quote the documentation for -A:

       -A, --all
       Like -u, but match <filepattern> against files in the working tree in addition to the
       index. That means that it will find new files as well as staging modified content and
       removing files that are no longer in the working tree.

Note the critical word: <filepattern>. You need to give it a pattern that matches, recursively, all the way down your tree.


I had a similar problem on Windows where I git add --all left some files untracked, problem was that there were several files with different casing 'test.php' and 'Test.php' so git tracked Test.php and not lowercase version of it.

This may help someone in future and save some head scratching.


I had this very issue the past couple of days with BitBucket. I am working on a project that is being tracked in its repository by Visual Studio 2013 Community Edition.

However I had used Git Bash on occasion to manually do commits and that's when things started to go wrong and files were simply being ignored. Tried to reclone the repo but this didn't help.

Finally I found that if you go into Visual Studio > Team Explorer > click on Sync, Visual Studio will do a pull and then commit and push any untracked files.

You could do the same manually through Git Bash if you like the console like I do.

Hope this helps someone.


I had this issue because I cloned somebody else's repository into my project. When I cloned it, there were already .git and .gitignore folders/files from their project. After deleting those pre-existing git files and starting over with git again, it works fine.

참고URL : https://stackoverflow.com/questions/7726131/git-add-a-is-not-adding-all-modified-files-in-directories

반응형