Search code examples
linuxgitbackupusb-flash-drive

Site Backup on Flash Drive with Git


I'm new to git, so forgive me if I've missed the boat completely. I am coding sites on my laptop and in addition to Dropbox I would like to have a backup of everything that I've done stored elsewhere. This is when I learned about git. I understand that it keeps track of all of the changes made (and committed), but what happens to the actual files that I've changed? What I'm asking is probably best explained by an example.

I have set up a git repo on my laptop to manage all of the changes made to MySite/ and all of its files and folders (index.php, img/, css/, etc.). I have also created a --bare git repository on a flash drive. I have pushed the original repo to that location. I am able to use git log to successfully view the history, but when I access the flash drive I notice that the contents of MySite/ are not there (or at least viewable). What do you suggest that I do to be able to work from the flash drive and then later push those changes to the laptop while still being able to work from the laptop as I am used to?


Solution

  • Just have both be non-bare repositories. It's simplest probably just to delete the bare repo (since it sounds like there's currently nothing unique to there), then run:

    git clone /laptop/project /thumbdrive/project
    

    where /laptop/project is the main non-bare repo, and /thumbdrive is your mounted thumbdrive.

    Now, /thumbdrive/project is a non-bare repo. Thus, you have two non-bare repos (meaning both have working directories), and you can feel free to work and commit with both of them, then pull (or push if you're careful) between them.

    Bare repos are used when you want a copy you will not work directly out of (e.g. a pure backup, mirror, or server).