Git seems to be tracking the java folder, but I can't commit changes to the specific file MainActivity.java
. I get a "Changes not staged for commit"
The diff shows the changes, but I can't commit it.
Also, I can't go down into the folder in Github.
Edit: When I do git status
in the command line, I get
user:JustJava juil$ git status
HEAD detached at 93ea9a1
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: app/src/main/java/com/example/android/justjava (modified content)
no changes added to commit (use "git add" and/or "git commit -a")
Edit 2: I have checked out the latest commit as some have suggested but still get the detached head error.
Edit 3: I tried adding the file itself w/ git add
but got an error that the directory is a submodule.
JustJava juil$ git add app/src/main/java/com/example/android/justjava/MainActivity.java
fatal: Pathspec 'app/src/main/java/com/example/android/justjava/MainActivity.java' is in submodule 'app/src/main/java/com/example/android/justjava'
I tried running git submodule status
and got the error
fatal: no submodule mapping found in .gitmodules for path 'app/src/main/java/com/example/android/justjava'
I tried deleting .git
in the submodule, but the same error keeps popping up.
Since justjava
folder turned out to be a submodule, in the super directory, I called git rm -rf --cached justjava
as suggested by @fusiongate and answered in this question.
This works in that it allows the file to be added and committed, but the commit history on this file is lost.