Android Studio crashed now can't push to GitHub
This morning AS crashed on statup. I rebooted and it seemed to startup fine. However, when I try to commit and push to GitHub via AS I get an Internal IDE error. I’ve tracked down a range of errors but am unsure what they mean and how to fix them:
- AS IDE error: collectInfoToPush | Couldn’t collect commits to push….fatal: bad revision ‘origin/master..master’
- cmd line: git status: Your branch is based on ‘origin/master’, but the upstream is gone.
- cmd line: git fsck: error: bad ref for refs/remotes/origin/master: dangling blob 0d40b3eceae21f1bfdd851fe137a40a3fd624437……(many of these)
I apologise I don’t know much about git other than the very basics. I’m guessing that somehow my local repo lost tracking with my repo on GitHub when AS crashed. Any suggestions anyone has would be greatly appreciated.
- Forking my own repo
- How to install portia, a python application from Github (Mac)
- Pull request within one project/branch?
- How to delete something that was accidentally pushed
- Instead of Committing Files, I hit 'Sync' in GitHub app
- Fail upload jar into github with maven
One Solution collect form web for “Android Studio crashed now can't push to GitHub”
Ok after some help from the comments I have got git to work again from Git Bash and from AS. I did the following:
git status: says my upstream is gone.
Read this to understand git jargon better: https://stackoverflow.com/a/21616241/2815375
git branch –unset-upstream: to remove the reference to upstream. Gets rid of the error message. From same link.
git gc –prune=now: I pruned all dead files. From https://stackoverflow.com/a/7614419/2815375
This gave me an error saying my origin/master was bad.
rm .git/refs/remotes/origin/master: removed this file. From https://stackoverflow.com/a/15458951/2815375
Did step 4) again. Everything fine now.
git remote show origin: to ensure remote properly defined.
git push –set-upstream origin master: to ensure proper tracking and everything synced up to date. From https://stackoverflow.com/a/12694311/2815375
git status: “your branch is up to date with origin.master”
However still didn’t work in Android Studio. Realised I has to do it for every submodule.
Do this for every submodule
Everything works in AS now too.
Hope this helps.