I have been following the basic instructions for an Android project on the integrated Github but, even on the very initial commit, I am getting an error from the integrated Github feature within the Android Studio 2023.1.1 Patch 2 ("the IDE").
Here are the steps I have taken:
- Create a repo using the github.com website, say GHTest1
- Go to the IDE and start a new project named GHTest1 with just the Hello World view
- Within the IDE, Enable Version Control under VCS, choosing Git from the dropdown menu
- Do an initial commit from the IDE
- Do the initial push from the IDE
After step 5, I get a "Push rejected Push to origin/main was rejected" within the IDE.
The error comes with hints, saying that the "Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref." Since this is the initial commit and no other repo is pushing to the same ref, this is not the case.
It also says, "You may want to first integrate the remote changes (e.g., ‘git pull …’) before pushing again." But I can’t actually do a pull: when I try, it asks for the branch but I do not have any branches yet.
Is the IDE for Android Studio not working with github or am I missing something basic? Thanks for any help!
I’ve tried this several times and reduced it to the minimal case I’ve described. I expected github to work as intended: accept my initial commit and then allow me to check out files for further development.
2
Answers
You can try to execute the following command on the Git Bash:
Probably your github repo contains a README.md. If this is the case, you can simply ignore and make a
or you can try to git pull before to get the README to your local branch, and then git push. If you canĀ“t make a git pull, I recommend you to do the first option I mentioned.