Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 451
yusufonderd Avatar asked Feb 04 '16 15:02

yusufonderd


3 Answers

Github helpfully provides a guide for adding an existing code base into a repository which already exists, here. Whilst not specific to android studio, it will allow you to use whatever normal commit method you use.

In a nutshell:

  • navigate to your code repository
  • run the command git init
  • add the files to commit with git add .
  • commit the changes : git commit -m "your commit message"
  • add the remote origin : git remote add origin your@git:repo/name
  • verify the remote URL git remote -v
  • push the changes git push origin master
like image 122
gabe3886 Avatar answered Nov 03 '22 22:11

gabe3886


To push an android studio project to an empty git, follow these steps:

  1. Go to terminal and change working directory to your project root using cd command and enter below commands.
  2. git init
  3. git status -> This would output you list of files in red color.
  4. git add . -> Adds all the files to local version control.
  5. git commit -m "Some Commit Message"
  6. git remote add origin repository_url.git Example: git remote add origin https://github.com/ramakrishnajoshi/JetpackNavigationComponent.git
  7. git push --set-upstream origin master -> A new branch is created with name master and all the code will be pushed to this branch.
  8. 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

like image 4
Ramakrishna Joshi Avatar answered Nov 03 '22 22:11

Ramakrishna Joshi


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 origin

  • make the remote repo bare with git config --bool core.bare true

  • Then 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.

like image 2
Marcin D Avatar answered Nov 03 '22 21:11

Marcin D