Category Archives: Git

Remove Unwanted Files From Git History

4.50 avg. rating (87% score) - 2 votes

Here’s an example of how to remove every *.pyc file from every commit in Git history. It is adapted from this Git help page.

Rewrite history

Run git filter-branch, forcing (--force) Git to process—but not check out (--index-filter)—the entire history of every branch and tag (--tag-name-filter cat -- --all), removing the specified files ('git rm --cached --ignore-unmatch *.pyc') and any empty commits generated as a result (--prune-empty). Continue reading Remove Unwanted Files From Git History

Adding Git version control to web sites

3.00 avg. rating (63% score) - 5 votes

Here’s a little script I made to make it easy to put a number of existing web sites residing under /var/www under version control by Git. Regarding security, it is obviously not a good idea to initialize the Git repository directly under the site directory, since from there it might be served by the web server to the outside world. And that is not what I want. Instead what I want is to have the Git working directory directly in the site directory that is served, and the repository somewhere else. That is perfectly possible with Git, just by setting one or two environment variables. Continue reading Adding Git version control to web sites