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

GitGithub

Git Problem Overview


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

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

You need to clone the repository on your second computer.

git clone [email protected]:myusername/myrepo.git

Now you can use git pull and git push to keep your local repository in sync with the one on GitHub.

Solution 3 - Git

You want to checkout the repository on the other computer, you do not want to fork it.

Solution 4 - Git

Starting working on another machine do the next:

1- Creat a new directory on your local machine to have your work saved to it.

2- from that newly created directory, open Bash( assuming that you already have git installed on your machine) by clicking the right mouse click and you will see (Git Bash here).

3- on Bash type git clone (your Repo URL OR ssh key). press enter

4- just done. :)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionZandorfView Question on Stackoverflow
Solution 1 - GitNick BerardiView Answer on Stackoverflow
Solution 2 - GithammarView Answer on Stackoverflow
Solution 3 - GitbeaganView Answer on Stackoverflow
Solution 4 - GitZaid_Code36View Answer on Stackoverflow