1

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.

smarber
  • 4,829
  • 7
  • 37
  • 78
LightCC
  • 9,804
  • 5
  • 52
  • 92
  • https://help.github.com/articles/duplicating-a-repository/ This looks like it has the instructions you need, last section. Mirroring a repository in another location – Jim Sep 05 '17 at 14:50
  • @Jim This still uses the tool/git command-line to connect to the remote repo, (it requires an interactive Git session), and I'd have to clone it first, which is the piece I'm having trouble with. – LightCC Sep 05 '17 at 14:53
  • I think, you can do this with the git tools, outside your firewall. Then walk this repo into your site, we will call it the mirror repo. Then do a git clone from the mirror and make your changes. Push your changes to the mirror repo. Walk your mirror site back outside your frirewall where you can push/pull to sync up with github. – Jim Sep 05 '17 at 16:57
  • If you cannot clone it how are you going to pull/push if you bring a clone somehow? – phd Sep 05 '17 at 19:00
  • Well, I found out what my issue was with the direct connection - I needed to setup my company proxy in Git itself. I'm still curious in this answer - there should be a way to setup the .git directory after manually plopping the code into a directory from a given branch or commit... – LightCC Sep 05 '17 at 19:06
  • 1
    A commit in git is much more than just the code, it also provides guaranteed verification of the commit's parent and all of it's code, and by extension it's parent and so on all the way back to the beginning. In fact in most repos, you'll find may commits that share their exact code base with other commits on the tree. Without that unique relationship with every other object in the history, it will never be able to resolve the code's place in the history. – LightBender Sep 06 '17 at 01:44
  • @LightBender Thanks - I just watched a Pluralsight Git tutorial that explains everything in the .git directory - that makes sense now. So Github's zip file is just the working directory with none of the Git information attached at all. So it looks like you must do the remote Git clone through the web (and in my case, the company proxy) to get the .git folder info – LightCC Sep 06 '17 at 17:19

1 Answers1

1

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.

LightBender
  • 4,046
  • 1
  • 15
  • 31
  • Okay - so you basically create a "fake" (or duplicate copy, if you will) of the "cloud" remote repo. i.e. Copy Github repo onto USB, and use the USB repo as the remote repo for the PCs behind the firewall or off-network. – LightCC Sep 06 '17 at 17:22
  • Exactly, although I'd probably call it a "bridge" rather than a "fake" – LightBender Sep 06 '17 at 17:43