Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add existing Android Studio project to existing GitHub repository

I've created a project new project in Android Studio and I want to add it to an existing GitHub repository which is currently empty.

I have tried the answer from this question: Replace GitHub repository with a new Android Studio project while preserving old commits but once I get to the final git push I get an error saying fatal: No configured push destination.

I have also tried https://github.community/t5/How-to-use-Git-and-GitHub/How-to-link-an-existing-Android-Studio-Project-to-an-existing/td-p/1946 but this uploads the project to the wrong GitHub account. I have two GitHub accounts which I think was the problem for this solution and I have since logged out of the account I don't need.

Are there any other ways to connect to an existing GitHub repository?

like image 603
Tori Harris Avatar asked Nov 22 '18 12:11

Tori Harris


2 Answers

Most probably you forgot to add a remote. you can check your list of remote using the following command.

 git remote -v

If there exist no origin, try add a remote using:

git remote add <remote name> <remote url>

(Remote url is your repository url, for example: https://github.com/user/repo.git)

Then you can push using the following command:

git push <remote name> <your branch name>
like image 84
Md Golam Rahman Tushar Avatar answered Sep 18 '22 11:09

Md Golam Rahman Tushar


The first thing you have to do is to create your local repository (on your machine)

git init

As you are trying to do a git push, I assume you already have done that. So the next thing you have to do is to define a remote repository (github) for your local repository to push on :

git remote add origin https://github.com/<user>/<repo>.git

You then can do your push but with a few more paramters.

git push -u origin master

That will tell git to push your commits to the master branch on your origin remote repository

More information on git remote here : https://help.github.com/articles/adding-a-remote/

like image 44
Muldec Avatar answered Sep 18 '22 11:09

Muldec