Reputation: 461
I removed a folder from my git repo by mistake with git rm
commands.
Now, whatever modification I make in that fold will not show up in git status
How can I make git track this missing folder again? Thanks.
Upvotes: 1
Views: 808
Reputation: 1329092
git rm
alone would not prevent git status to show differences in the folder.
Check if you have a .gitignore
rule which would explain why git status does not work in that folder.
git check-ignore -v -- yourFolder/aFile_inside_that_folder
If it displays a .gitignore
filename and a line, you will know why you don't see anything.
You can then delete that rule, and git status
should work again.
From the OP Jim Wang's comment
I tried the command you provided, and the output is:
fatal: Pathspec 'myFolder/setup.sh' is in submodule 'higherleveFolder/myFolder'.
At the very beginning, "
myFolder
" is a separate repo I cloned inside the original repo.
Could you tell me how to clean up everything and make git track "myFolder
" again?
If you have a .gitmodules
in the main repository root folder, try what I recommended in 2013:
0. mv a/submodule a/submodule_tmp
1. git submodule deinit -f -- higherleveFolder/myFolder
2. rm -rf .git/modules/higherleveFolder/myFolder
3. git rm --cached higherleveFolder/myFolder
# Note: higherleveFolder/myFolder (no trailing slash)
From there, you can git add
, commit
and push
higherleveFolder/myFolder
content.
Upvotes: 1