2

I tried checkout and discard this library with git checkout command, but seems it does not work for me.

I tried to remove this folder, but after that git wants me to add this deleted folder to a commit, but I don't want to track it or push to server.

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) (commit or discard the untracked or modified content in submodules)

modified: Libraries/some_sdk (untracked content)

Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277

2 Answers2

2

One way would be to go in that submodule folder and do in it:

cd /path/to/repo
cd  Libraries/some_sdk
git reset --hard

That should reset its index.

Then, a git status from its parent repo should mention the (submodule) folder anymore.

I don't want to track it or push to server.

It won't be tracked from the parent repo: said parent repo only references the gitlink (special entry in the index) representing the SHA1 of the submodule repo.

I tried to remove this folder, but after that git wants me to add this deleted folder to a commit

To remove a submodule, see "How do I remove a submodule?"

cd /path/to/repo
git submodule deinit Libraries/some_sdk
git rm Libraries/some_sdk
# note: no trailing slash
rm -rf .git/modules/Libraries/some_sdk
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

If by deleting the folder git wants to "delete" the changes. It's because it's already been tracked. You can remove them with

git rm -r [path to dir]

In the case they were not tracked

git clean -df would do the trick (you can use the -n flag instead of -f for a dry-run that would tell you which files would be removed.