user596075
user596075

Reputation:

Sharing a Repository Among Two Computers

I'm having a hard time grasping how I can accomplish the below task:

  1. I have a git repository on Computer1
  2. I push to a repository on GitHub
  3. Now I am on Computer2 that has zero footprint of this repository and I want the repository to also live on Computer2
  4. I want to be able to work on this repository's code on both computers

I'm having a difficult time determining what exactly needs to happen. For Step 3, I would think I'd do a fetch or a pull, but (unless I'm reading this wrong) that only seems to pull down new and updated files. There could potentially be old files in that repository, but because Computer2 has none of them I'd want them all (I guess an actual copy of the repository).

I wouldn't think I'd want to create a branch or fork the repository, because I'm not looking for 2 separate versions out there.

And as for Step 4, once the prior steps were complete I would think on each computer I'd just do a pull to get the updated files.

Is my understanding correct, and if not how am I to accomplish the above tasks?

Upvotes: 0

Views: 378

Answers (3)

John Fisher
John Fisher

Reputation: 22717

Alternate:

Clone from Computer 1 to Computer 2. Then, you can work between your two computers, pushing from 2 to 1 as if 1 was the master for 2. When you're finally ready to push to GitHub, either computer can be used to push to GitHub, but default behavior makes it easier to do from computer 1.

Upvotes: 0

Amber
Amber

Reputation: 527258

You want to clone the github repository on Computer2.

From then on, when you're done doing work on a given computer, you'll need to push your changes to github (to update your online copy), and then when you arrive at the other computer, pull those changes from github to the local copy to update it.

Computer1 --push--> GitHub

Computer1           GitHub --clone--> Computer2

 changes
    |
    |
    v
Computer1 --push--> GitHub            Computer2

Computer1           GitHub --pull---> Computer2

                                       changes
                                          |
                                          |
                                          v
Computer1           GitHub <--push--- Computer2

Computer1 <--pull-- GitHub            Computer2

Upvotes: 3

three
three

Reputation: 8488

First install git and then clone your repository with the url you get from github. Afterwards all you need to do is pull and push to keep the two in sync.

Upvotes: 3

Related Questions