问题
I am new to Android Studio and have began developing a Navigation Drawer app.
After having made a mistake in a commit, I played around with the Version control's "Checkout Revision" and now I can no longer push my project onto Github due to a "Detached HEAD".
How can I fix this problem? My app runs perfectly fine in the emulator.
Thanks
回答1:
you can go to VCS menu then Git, Branches, then in Git Branches dialog click on item below local branches then checkout branches and then accept your default branches. it will connect your project to it's default branch and you can commit your project.
回答2:
When you are in a 'detached head state' in Git, it means you are currently viewing history according to a past commit that is not on a branch. A few things need to happen based on what your goal is.
If you want to continue your code in the currently checked out version? If so, you should check back out to the most recently made commit and then un-do history with git revert
or git reset
, whichever makes more sense for you.
If you want to just go back to your most recent commit and continue to work as normal, git checkout <newest SHA>
will work totally fine.
回答3:
To get rid from Detached Head you need to know why this problem is arrived. Its Showing Detached Head because you merge your project several times(or atlas twice) by just committing your project locally. What you need to do is that by every time you merge your project just commit it locally as well as to server branch too. This will resolve your problem as it does mine.
来源:https://stackoverflow.com/questions/39938633/detached-head-issue-in-android-studio