The way most people use a USB stick is to just work directly from it. However, that is the wrong way of doing it. That is why I will show you how to use git on a USB stick
Working directly from the USB stick has several problems to it.
- Only one copy
- Difficult to backup.
- No version control
- Need USB stick to access files.
- Shortens the life of the USB stick as it is not designed to be constantly written to.
If you think the first three items is the same thing I suggest you go read about the deference between a copy, backup, and version control.
One of the nice things about using a cloud service like OneDrive or Dropbox is that your data is sync via a central point. These ensure that there is always more than one copy of the data and you do not have to be connected to the central point in order to use and edit your data. Every device holds a copy of the data and the changes are syncs when a connection becomes available. Another nice feature is that most cloud storage services have some basic form of version control. Both features have saved my bacon in the past so I really wanted my new non-cloud set up to have these features.
It turns out the solution is quite simple and makes use of a tool I already use for my code. The tool is Git. I used Git to create a central repository / no working directory on the USB stick using the following command.
cd path_to_central_reposity_folder_on_usb_stick git init --bare --shared=all
Then all I had to do was to clone it to a folder on my computer.
cd path_to_where_i_want_my_files_on_computer git clone path_to_central_reposity_on_usb
Now I can work on my files and when I am done I just commit and push the changes to the USB stick.
git add -A git commit -m "Made some changes!"
Push changes to USB stick
git push origin master
When working on another computer I just connect the USB stick and pull repository. Do my work, then commit and push. It is that simple.
This relatively simple setup solves the issues above when working directly from the USB stick.
- There is a copy on every computer I use
- Since there is a copy of the data on the computer the data are backed up when the computer is backed up (that is every day)
- We get version control via Git
- We only write to the USB stick when done working or changing computer/OS.
This is an extremely robust setup and I am quite happy with it.