Git Automatic Ignore Exe, Blobs for Linux
Thursday, September 08, 2011 |
Edit Post
In my opinion, Git is a programmers program. It is fast, feature-rich yet intuitive, kind of like Google...there's a new treasure waiting to be found around every corner. The philosophy behind Git appeals to me; there's sure to be a lot to learn by appreciating it's architecture and studying its internals.
One of the few things that bugs me about Git is what happens when you finally realize that you have been committing unnecessary -massive- binaries such as database files and executables -especially if they are modified frequently.
The problem here is that if any single bit changes, the repository must make a new, albeit compressed copy of the whole mess, while of course keeping all previous copies archived for future reference... This situation sees the repository size quickly bloat. While there are (Git) methods to undo such mistakes, it's by no means easy or fun to do. At least for myself, I am not proficient enough with Git to fully understand the entire process.
I've been doing a fair bit of compiling lately and have found the output binaries are getting in the way of my workflow -sure there are means to avoid this such as having make files output to /bin directories and then explicitly reference them in a .gitignore file, but that's not practical in my situation.
In Windows environments things are actually a little easier as file extensions are almost always employed and they make filtering a snap. In Linux, however, things are a little trickier...
As such, I've put together a script that employs the file utility in order to identify file MIME types, filter and then automatically add to them to .gitignore. It can run from within any directory of the repo in order to create per-directory .gitignore files, however executing it from the repo's root to create a top level .gitignore is probably good enough, and more maintainable.
If there's a need, I might implement a recursive maintenance utility, but for now it only deals with a single gitignore within the current working directory.
AutoGit -automatically filter files by their MIME type to avoid binary files, databases and other undesired content types.
Here's a direct link to the AutoGit bash script on GitHub.
$ Save it as a text file named autogit or something else flavorful.
$ chmod +x autogit
$ put it in the root of your git repo OR even better, place it in your PATH somewhere like /usr/share/bin
$ cd /your/git/repo
$ do autogit or ./autogit as appropriate
$ autogit will append the filepaths it found that have been identified and dump a report + git status
$ By default, the MIME types application/x-executable and application/octet-stream are enabled. Edit the script to add/modify desired MIME types.
Picture is of marshland adjacent to Pitt Lake near my place... I originally emailed this post in from my iPhone 4 which looked OK in the mobile version of Blogger, but had weird line breaking going on that I had to later undo from a browser...Just me testing.
One of the few things that bugs me about Git is what happens when you finally realize that you have been committing unnecessary -massive- binaries such as database files and executables -especially if they are modified frequently.
The problem here is that if any single bit changes, the repository must make a new, albeit compressed copy of the whole mess, while of course keeping all previous copies archived for future reference... This situation sees the repository size quickly bloat. While there are (Git) methods to undo such mistakes, it's by no means easy or fun to do. At least for myself, I am not proficient enough with Git to fully understand the entire process.
I've been doing a fair bit of compiling lately and have found the output binaries are getting in the way of my workflow -sure there are means to avoid this such as having make files output to /bin directories and then explicitly reference them in a .gitignore file, but that's not practical in my situation.
In Windows environments things are actually a little easier as file extensions are almost always employed and they make filtering a snap. In Linux, however, things are a little trickier...
As such, I've put together a script that employs the file utility in order to identify file MIME types, filter and then automatically add to them to .gitignore. It can run from within any directory of the repo in order to create per-directory .gitignore files, however executing it from the repo's root to create a top level .gitignore is probably good enough, and more maintainable.
If there's a need, I might implement a recursive maintenance utility, but for now it only deals with a single gitignore within the current working directory.
AutoGit -automatically filter files by their MIME type to avoid binary files, databases and other undesired content types.
Here's a direct link to the AutoGit bash script on GitHub.
$ Save it as a text file named autogit or something else flavorful.
$ chmod +x autogit
$ put it in the root of your git repo OR even better, place it in your PATH somewhere like /usr/share/bin
$ cd /your/git/repo
$ do autogit or ./autogit as appropriate
$ autogit will append the filepaths it found that have been identified and dump a report + git status
$ By default, the MIME types application/x-executable and application/octet-stream are enabled. Edit the script to add/modify desired MIME types.
Picture is of marshland adjacent to Pitt Lake near my place... I originally emailed this post in from my iPhone 4 which looked OK in the mobile version of Blogger, but had weird line breaking going on that I had to later undo from a browser...Just me testing.
Labels:
Tech
Dynamic Page QR Code
Popular Posts
-
Product Manager Cover Letter: This real cover letter worked successfully at getting an interview as a product manager. Use it as a templat...
-
Creating randomized valid file paths is a common requirement for many applications such as the case of short url redirects. The Goo.gl url s...
-
If you're interested in placing QR tags dynamically on your site, here's how I did it in less than 5 minutes thanks to Google's ...
-
Cover Letter Examples that I have used successfully to get a job interview: Further to my last post on this topic, there's no substi...
-
Is there a scientific reason that can explain Why People are So stupid? It's not surprising that so many people take advantage of being...
-
Sample for Cover Letters Writing an effective cover letter is essential to get yourself noticed. Use your cover letter as a sample of your...
-
Decoded HTML Encoded HTML Entities /** * Encode HTML tags as HTML Entities * using jQuery * * Code takes raw...
-
In my opinion, Git is a programmers program. It is fast, feature-rich yet intuitive, kind of like Google...there's a new treasure waitin...
-
Blogger RSS URL s can be customized to syndicate content in a user friendly way. This is especially important if you operate a multi-issue b...
-
The example below uses Google's OpenID API to request and validate the user's GMail address. The visitor is first directed to Google...
0 comments:
Post a Comment