Search code examples
gitbackupcommitrepogit-history

What is the best way to create an offline backup of a git project (Unreal Engine)?


I've just started using Git and GitLFS for version control on game projects that I'm making with the Unreal Engine. These projects use a lot of large binary files and so they're expensive to store on an online server for long periods of time.

Accordingly, I want to make offline backups of my project that contain all files and assets. This is for general backup purposes during development, and also for longer-term backup, e.g. when I have a project that I've finished working on for the time being, but might want to pick back up later.

From what I currently understand, one option is to clone my repository to a new location on my desktop PC, then literraly just delete the (hidden) .git folder from that new cloned version of the repo, and then zip the project folder. I can then delete the remote repository. When I want to continue development, I can unzip the folder I zipped up, open gitbash, and run "git init" to start a new repo. However, that obviously won't restore my old branches or commit history.

Is there an alternative way of backing up a repository if I want to keep alive things like the branches and commit history?

I've considered whether the correct approach is simply to clone the remote repo straight to the backup drive. However, I don't know what would happen if I then deleted the remote repo. Could I simply create a new remote repo and then associate it with my local backup repo by opening GitBash in the backup folder and calling e.g. "git remote set-url origin git://new.url.here" ?


Solution

  • You can backup a copy of your folder containing your git project, that's it. Later if you want to have it on a new remote repository you could change your remote:

    git remote set-url origin https://github.com/OWNER/REPOSITORY.git
    

    If you worked only locally you add the remote:

    git remote add origin https://github.com/OWNER/REPOSITORY.git