I can't commit after pushing repo to github. What i'm basically trying to do is to clone some code from one github repository, do some changes and push the code to another github repository. I make some local repo, cloned the code, pushed the code to another GH remote repository and it all worked out fine, now when i'm making some changes on my local repo and i'm trying to 'add .' then 'commit -m' i'm getting this message.
EDIT:
After 'git add -A':
Any thoughts?
You have a submodule.
Specifically, your output includes the following (which I had to retype, so this might have typos—try not to use screenshots if plain-text will do; this avoids manual-copy-paste errors):
Changes not staged for commit: ... modified: FakeApiReqresTest (modified content)
The parenthetical phrase (modified content)
is what tells us that FakeApiReqresTest
is not a file.
The submodule in question is another Git repository. This other Git repository has a modified working tree, i.e., what's in its working tree is not committed yet. The superproject repository can only record the hash ID of one specific commit in the submodule Git repository per superproject commit. The git add
command, run in the superproject, will put the correct commit hash ID into the superproject Git index / staging-area, based on the commit that is currently checked out within the submodule. (Is that confusing? It is to me 😀 even though I wrote it.)
What this boils down to is the fact that you must first:
The result is either:
git push
to wherever it goes: remember when doing this that submodules normally live in "detached HEAD" state, so this git push
has one extra wrinkle you must handle), oror perhaps even both. If you wind up changing the submodule's working tree while doing this, it's generally wise to re-test the superproject as a whole before proceeding.
Once you have the correct commit actually in the submodule, and the submodule's git status
itself is "clean", you're now ready to git add
the submodule's commit to the superproject's index / working-tree, using git add
within the superproject. This may give you "changes staged for commit" by updating the gitlink in the superproject's index.
Do not copy-paste these without at least reading through and thinking about them. Which commands you should use will depend on many things.
# enter the submodule
cd FakeApiReqresTest
# inspect this Git repository; add and commit
git status
git diff
git add -u
git diff --cached
git commit
<enter appropriate commit message>
# send new commits upstream before using them in superproject
git push origin HEAD:somebranch
# update the superproject's gitlink
cd ..
git add FakeApiReqresTest
# verify, commit, etc
git status
git submodule status
git diff --cached
git commit
<enter appropriate commit message>