Troubleshooting misplaced .git directory (nothing to commit)
Solution 1:
Found what was wrong. I don't understand how, but .git
directory path somehow was changed to other path than I was working in. So then anything I changed was not checked, because git was checking in other place. I noticed it, when I reinitialized it and it showed that it reinitialized entirely different directory. When I cd ..
from my current directory and cd
to it back again and then reinitialized yet again, then it switched back to correct .git
directory and started seeing my changes.
Solution 2:
This must have happened because by mistake you reinitialized git in the same directory. Delete the .git folder using the following command Go to repository you want to upload open the terminal and then use the following commands
- remove the .git repository
sudo rm -r .git
- Now again repeat from initializing git repo using
git init
- then
git commit -m "first commit"
git remote add origin https://github.com/user_name/repo
-
git push -u origin master
After that enter the username and password and you are good to go