'How to push Android Project to existing private empty repository in github with Android Studio?
I am trying to push android project to private empty repo with android studio . But I cannot find simple solution. How can I do this ?
Solution 1:[1]
To push an android studio project to an empty git, follow these steps:
- Go to terminal and change working directory to your project root using
cdcommand and enter below commands. git initgit status-> This would output you list of files in red color.git add .-> Adds all the files to local version control.git commit -m "Some Commit Message"git remote add origin repository_url.gitExample:git remote add origin https://github.com/ramakrishnajoshi/JetpackNavigationComponent.gitgit push --set-upstream origin master-> A new branch is created with namemasterand all the code will be pushed to this branch.- Wait till the code is pushed before doing any other operation in terminal.
After all this, you will get a message similar to Branch master set up to track remote branch master from origin
Solution 2:[2]
If you are pushing to a private repo in a local location ie. a private server.:
Assuming you have set up local git repository, cd into the remote location and clone your local repository with
git clone 'path to local repo'cloning will set the local repo as a remote, so we have to remove that with
git remote remove originmake the remote repo bare with
git config --bool core.bare trueThen in your local repository add the remote with
git remote add origin 'location to remote git repo'
Now you should be able to push to remote in Android studio.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Marcin D |
