Setting up git on a restricted access server - labordynamicsinstitute/replicability-training GitHub Wiki
This tutorial assumes that you are using a restricted-access environment, with limited or no internet access. It will describe how to synchronize a repository INSIDE with the repository OUTSIDE, which may be on Github, Bitbucket, or Gitlab.
+------------------+ || +---------------+
| git (cloned) | || | git (cloned) |
| | =====> || ========>| | ========> [ Github ]
| I N S I D E | || | O U T S I D E |
+------------------+ || Firewall +---------------+
Setup OUTSIDE
- Set up a new OUTSIDE repository - for discussion's sake, create a README.
- On an outside system, clone that repository (follow the instructions on Github/Gitlab/etc. when creating the repository). Do not add any files to it.
Setup INSIDE
On the INSIDE, initialize a Git repo for offline access (ref1, ref2)
mkdir myproj
cd myproj
echo "Hello" > README.md
git init
git add README.md
git commit -m "first commit"
Now we want to git bundle
this repo (we also create a tag, to flag which version we did here)
git bundle create file.bundle master
git tag -f lastOUTSIDEbundle master
Now the file file.bundle
can be moved _somehow _to the OUTSIDE system (e.g., email, sftp by authorized users, etc.). The example below assumes somebody has scp
access to the system.
> scp INSIDE:/path/from/file.bundle OUTSIDE:/path/to/file.bundle
On the OUTSIDE system, edit the $GIT_DIR/config file (usually in the .git
directory), and add the following entry:
[remote "bundle"]
url = /path/to/file.bundle
fetch = refs/heads/*:refs/remotes/origin/*
Now, to update the repo on OUTSIDE, you call
git pull bundle
NOTES
- it may be more useful to use a branch on OUTSIDE that tracks the INSIDE system, whereas
master
tracks the Github - this needs to be tested.