Reputation: 593
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?
Upvotes: 5
Views: 5661
Reputation: 9
Steps...
git init
git remote set-url origin [email protected]:username/repo.git
git add .
git commit -m "my commit"
git push origin master
Upvotes: 0
Reputation: 2375
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>
Upvotes: 6
Reputation: 4901
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/
Upvotes: 3