How to zombie-proof your Git repo

offendingcommit

Jonathan Irvin

Posted on November 5, 2019

How to zombie-proof your Git repo

Photo by Scott Rodgerson on Unsplash

Dear Friends,

This is a letter to all those who come after me. I pray you have shelter and food.

The year is in the not-too-distant future. Society has crumbled. Dev.to has become a decentralized haven for rebuilding society as we know it.

Welcome friends, to the end times.

In order to rebuild society, we need to track our progress! Our Founding Father, Linus Torvalds, knew this day would come. We didn't realize it would come sooner than later.

If you're receiving this message, I doubt this link will work, but if you're fortunate to be one of The Connected, here it is. If you're like the rest of us, let me share the details.

We all know Git is decentralized, but ever since the Happening, there has been no way to sync up like the Golden Days of the Git Hub. That is not true, friends!

Git Bundle

Did you know that you can package your entire repo into 1 file? All you have to do is type this command:

git bundle create file.bundle master
Enter fullscreen mode Exit fullscreen mode

This creates a file called file.bundle based on the master branch that contains all tags, branches, etc.

Make a tag to mark the point in which you are transferring the crucial, life-saving files so the next time you have to risk it all to transfer changes, you can calculate the difference easily.

git tag -f godSpeed master
Enter fullscreen mode Exit fullscreen mode

This makes a tag labeled godSpeed.

What I can't provide for you, friends, is how to transport the file. You will need to get it into digital format and transferred: be that a flash drive, Compact Disc, Mule, or a steadfast runner.

I pray that this file makes it to its destination. After all, society depends on it!

Once your file has arrived safely, have your other Outpost Tech run the following command to extract the file and clone the repository.

git clone -b master <location of file.bundle> <output folder>
Enter fullscreen mode Exit fullscreen mode

Once they execute this, the origin will point to the same filename, so for future extractions, keep this filename the same.

Future Extractions

The future is bright, friends, and we're able to send more changes to the Outpost Colonies.

git bundle create file.bundle godSpeed..master
git tag -f godSpeed master
Enter fullscreen mode Exit fullscreen mode

This will calculate the difference between your last tag and the latest changes, and then we can reset the tag to a new, updated point in time.

You can optionally make a new tag if you want to keep track of how many times you have been able to make the long journey and saved humanity.

There are other options, friends, you can calculate a diff based off of tags that exist in both repos:

git bundle create mybundle v1.0.0..master
Enter fullscreen mode Exit fullscreen mode

You can create a bundle off of the number of says since you last heard from your friends in the wastelands with this command:

git bundle create mybundle --since=10.days master
Enter fullscreen mode Exit fullscreen mode

Or you can bundle up a specific number of commits:

git bundle create mybundle -10 master
Enter fullscreen mode Exit fullscreen mode

Trust, but Verify

Your Outposts can run the following command to see if the bundle file is compatible with their current setup. Note, they will need to have installed at least one bundle.

git bundle verify file.bundle
Enter fullscreen mode Exit fullscreen mode

Conclusion

Society has crumbled, but we will prevail!

💖 💪 🙅 🚩
offendingcommit
Jonathan Irvin

Posted on November 5, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related