Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I code against one github repo on 2 computers?

Tags:

git

github

I have two computers from which I want to contribute to one github repo. How can I accomplish this?

like image 878
Zandorf Avatar asked May 15 '11 23:05

Zandorf


People also ask

How do I access my git repository on another computer?

in CMD go to folder where you want your app to be cloned to, for example cd C:/my_apps/ login to github and go to app you want to clone, press green button "Clone or Download", you will see SSH link, copy it. in CMD run git clone [email protected]:user/my-app. git (use SSH link you copied)

Can two people use the same GitHub account?

You can either use the same key on both or add multiple keys to your github account. If you attempt to use the same account for multiple people though it might get messy if you don't have a solid workflow.

How do I import code from one GitHub repository to another?

In the upper-right corner of any page, click , and then click Import repository. Under "Your old repository's clone URL", type the URL of the project you want to import. Choose your personal account or an organization to own the repository, then type a name for the repository on GitHub.


1 Answers

To keep both repositories in sync you should to pull the latest changes to your machine whenever you start working on the code.

To do this you want to execute

git pull 

...which is usually set up to pull from the default remote (origin) to your current branch. Git might complain if this isn't the case, and so the longer version will work as well:

git pull origin {branch_name} 

Note: this is the same process that you would use if two or more people were working on the same repo. Which is essentially what is happening, instead of two different people working on the same repository, you have two different machines working on the same repository.

If you are starting out fresh on a new machine all you need to do is clone the repo to it first:

git clone {remote_url} 

You get this url from your GitHub repo's home page. This command will make a complete working copy of the repo in a subdirectory.

like image 80
Nick Berardi Avatar answered Sep 23 '22 03:09

Nick Berardi