Backup code with git archive
I am currently working on a Facebook application using nodejs and other frontend goodies. While that’s all sweet and interesting, localhost can be used to play around after applying certain tricks that I described a while back. Some particular features (more specifically the share button) cannot be tested in a
environment, so I need to place the current code version on a test server and execute it from there.
While I’m coding, the last thing I want to do is to worry about git commits while my functionality might be breaking. I need to quickly see the results of my code changes. So I searched for a way to quickly pack my local code, and came across the beautiful
git archive command. As its name says, it allows me to generate an archive of my current code, but it can also just export the files without packing them (it’s called
I first exported the code as an archive,
g@local $ git archive --format=zip HEAD > ~/Desktop/work-in-progress.zip
Then I uploaded the archive on the testing machine with
g@local $ scp -v ~/Desktop/work-in-progress.zip email@example.com:.
Next step was to unpack it there,
deployer@remote $ unzip work-in-progress.zip
I then installed its dependencies
deployer@remote $ npm install
Starting the process was easy as pie,
deployer@remote $ npm run dev
I got myself a solid process consisting of just 4 steps, which can easily be the starting point of the production deployment when I get to that point.
For different use-cases where the versioning information is also needed, I find
<a href="http://rypress.com/tutorials/git/tips-and-tricks">git bundle</a> to be more appropriate.