How do I manually clone a Github repository to my PC?

2k views Asked by At

I'm having issues reaching the public Github site (github.com) using existing tools in my workflow (Visual Studio Git, Git Extensions), due to firewall/proxy rules I haven't been able to straighten out yet.

In the meantime, I'd like to manually replicate the Github repo locally. I'm hoping there is a way to do this that I'm just missing (with the ZIP download?) I realize there are also Git commands to create patches (git-format-patch and git-bundle, see this answer), but I don't see any way to create those on the Github website. When I grab the download .zip file, there is no .git folder - maybe I don't need that?

Question: Is there a way to manually replicate a Github.com Git repository on a local PC, without using the cloning options?

I tried creating a bare repository using Git Extensions, so I already have a .git folder - can I just dump the contents of the zip into that folder? I'm concerned because I want to pull in a branch other than master, and I can see some of the files in .git reference master currently, and this also likely wouldn't have references to all the branches (though that might not matter).

I believe I need the git patch or bundle files, but not sure how to create those on Github. I could do that from my personal PC outside the firewall and use sneakernet, but it should be possible to just pull down from Github - right?

Note: I can get to the Github.com website, just cannot complete cloning through the tools properly, likely because they are not logged into our authenticator (i.e. through SAML/SSO). I tried using oauth, etc. but it's not working directly. Regardless - there should be a way to complete a manual clone, and I'd like to understand how to do that.

1

There are 1 answers

2
LightBender On BEST ANSWER

This is similar to a situation I ran into consulting with a company when managing code intended for a cluster of machines that could not be connected to the network.

You will need a total of three repositories:

GitHub Repository
Bare repository on portable media
Destination repository

The bare repository on the portable media will act as your bridge

  1. Create a bare clone onto a jump drive or portable hard drive
  2. Carry the cloned repository to your new location
  3. Clone normally from the portable repository onto the system

To push data the other way, just reverse the process

  1. Push your local changes to the portable repository
  2. Carry the repository to a computer with git and a network connection
  3. Push the repository back up to GitHub

When you get the connection sorted (or the security requirements change) you just change the remote on the previously protected repo to point directly to GitHub.