Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link to existing GitHub repository

Tags:

git

github

heroku

I have created a repository on GitHub and would now would like commit changes to this repository using Git. I have a project file structure (created using Heroku) to be committed. What steps are required in order to link an existing GitHub repository with Git?

In the past I've used "GitHub for windows" UI to create a GitHub repository. This creates a file structure on my machine and as I update the file structure, the changes are recognised.

But this new setup is a little different in that the project already exists, and I want to link it to a new GitHub repository.

like image 377
blue-sky Avatar asked Oct 06 '13 15:10

blue-sky


People also ask

How to link to Another Git repository?

You also mentioned "linking" to the Git repository. The proper way to interact between repositories is by using remotes. You could convert /foo to a Git repository, register my-fake-repo as a remote, and then use normal Git operations between the two repos, without resulting to trickeries like at the top of this post.

How do I add a project to a GitHub repository?

Simple steps to add existing project to Github. 1. Create a new repository on GitHub. In Terminal, change the current working directory to your local project. ##2. Initialize the local directory as a Git repository. Add the files in your new local repository. This stages them for the first commit. git add .

How do I push to a remote repository in GitHub?

1 Answer 1. You need to add a new remote, pointing to GitHub, and then push to it. The steps: Create a repository on GitHub, without a README, completely empty. In your existing repository: git remote add REMOTENAME URL. You could name the remote github, for example, or anything else you want.

How do I create a GitHub repository without a README?

Create a repository on GitHub, without a README, completely empty. In your existing repository: git remote add REMOTENAME URL. You could name the remote github, for example, or anything else you want. Copy the URL from the GitHub page of the repository you just created.


1 Answers

You need to add a new remote, pointing to GitHub, and then push to it. The steps:

  1. Create a repository on GitHub, without a README, completely empty.

  2. In your existing repository: git remote add REMOTENAME URL. You could name the remote github, for example, or anything else you want. Copy the URL from the GitHub page of the repository you just created.

  3. Push from your existing repository: git push REMOTENAME BRANCHNAME. For example, if you named your remote github and you want to push master to it, you would do git push github master.

Let me know if you need anything else.

like image 74
janos Avatar answered Nov 14 '22 11:11

janos