During a project I had worked on in the past, I was provided with a computer for which access to the Internet was not allowed. Since I was working on a software project, I wanted to source control it and upload it to my private repository. And the handiest method was to do it through a USB Drive.
This article will walk you through the basic setup for this little trick. As most of the articles in this blog, the content will be based on Ubuntu.
Introduction
The basic idea is to setup a Git repository in a USB Drive, which will be used as a "bridge" between your offline computer and another computer with internet access. This way you could push changes into your favorite online repository host, while being able to develop and source control with Git seamlessly.
What you will need..
- The offline computer where you'll be developing.
- Computer with access to internet (if changes shall be uploaded)
- USB Drive, 4 GB (Size depends on project size, but USB Drives are inexpensive nowadays)
- Account in Git Repositories hosting ( eg. BitBucket, GitHub, GitLab)
If you don't already have an online repository created from your Git host, then I recommend you go here and follow the instructions in "1. Starting a Repository".
Once you have an online Git repository setup and its address copied into the clipboard, you could continue on.
Preparing the USB Drive
1. Formatting the Drive
First of all, we need to format the USB Drive. With the USB Drive plugged in, open "Disks" in Ubuntu.
![]() |
Figure 1. Screenshot of Disks on Ubuntu's Dashboard |
On the left panel of the screen, select your USB Drive. Then click on the setting button and select "Format..." as shown in screenshot below.
![]() |
Figure 2. Disks Interface |
The following window will appear. Just click "Format..." and an additional dialog window will also show asking if you're sure, just click on "Format"
![]() |
Figure 3. Format Options in Disks |
2. Partitioning the Drive
Back to the screen shown in Figure 2, click on the "+" button to create a new FAT partition. Set the settings as recommended in the following screen and click "Create".
![]() |
Figure 4. Partition Creation in Disks |
Note: The "Name" set in this screen will be used later, so save it.
3. Cloning Online Repository
Navigate to your USB disk. It should be automatically mounted once plugged in.
Clone the previously created online repository as shown below. (I will continue using the example repository from previous tutorials.)
![]() |
Figure 5. Cloning Repository into USB |
Note: Blacks rectangles are just to cover my username. This should be your username.
Then we just clone the repository as usual plus the "--bare" option: "git clone --bare". This option makes the created directory contain administrative files.
The preparation of the USB is now finished and ready to be used... Now let's take the USB and plug it into the offline computer...
Using the USB Drive
1. Cloning USB Repository @ Offline Computer
Once the USB is detected and mounted, open a terminal (Ctrl + Alt + Del). Know the path to the USB, it's usually similar to the one shown in Step 4, above.
Now, navigate to your workspace directory and clone the repository from the USB, as shown below.
![]() |
Figure 6. Cloning with --bare Option |
As mentioned above, you need to know the path of the USB Drive, since this is where you will be cloning from.
2. Making, Committing, and Pushing changes to USB
Go into the project working directory, make some changes, and commit them, as usual.
![]() |
Figure 7. Making, Adding, and Committing Changes |
Once the changes are committed. Run the "git push" command. Notice that the push automatically pushes it to the USB.
![]() |
Figure 8. Pushing Changes to the USB Drive |
Voila! Now developments in your offline computer are pushed into the USB Drive.
3. Push Changes to Online Repository.
Now, plug the USB back into the computer with internet access. Navigate to the repository in the USB, and execute the command as shown in the screenshot below.
![]() |
Figure 9. Pushing Changes to the Online Repository |
The USB Drive can now serve as a "bridge" between the offline computer and the one connected to the internet. Better yet, it could be used as a "travel development USB, or whatever application you find for this.
Conclusion
I hope you find this little trick quite handy. This is actually how I coped with developing in a computer without internet access and still wanted to keep a backup of the code in an online, private repository. It doesn't require so much time, and it's quite inexpensive. So I think it should be the most viable solution for mentioned case.
Feel free leave comments and suggestions! Cheers, and till next time.