How to remove a big file wrongly committed to a Git repo

Today I accidentally committed a multi GB file to the git repo of the project I was working on and pushed it. Damn! Because of that big file cloning the repo again would take a long long time. Removing the file locally and pushing again would not solve the problem as that big file is in Git's history. So I took a few moments to Google around and learned that that there actually is a git command that can rewrite history: filter-branch. This is how I removed that big file from history:
git filter-branch --tree-filter 'rm path/to/your/bigfile' HEAD

git push origin master --force
Both commands took a while to complete, but after that I had a light repo again. If you need to do this, be sure to keep a copy of your repo around in case something goes wrong. Here's an old, but still seemingly still correct blogpost by Dalibor Nasevic with some more info on the subject.
Few weeks ago I froze gems on my blog and ended up with a very big repository. So, I wanted to clean up the mess and remove permanently gems folder from the repository. git rm wasn't doing the job well, it only removes the folder from the working tree and the repository still contains the objects of this folder. After a quick search, I found that git-filter-branch was the command I was looking for.

Make git work better with GitHub

A few months ago I installed a command line utility called hub. I'm really fond of it. It's aim is to make it easier to interact with GitHub from the commandline. It's a wrapper around the standard git command. Once it's installed you can do stuff like this (take from the manual page)
# clone your own project
$ git clone dotfiles
→ git clone git://

# clone another project
$ git clone github/hub
→ git clone git://

# open the current project's issues page
$ git browse -- issues
→ open
# Example workflow for contributing to a project:
$ git clone github/hub
$ cd hub
# create a topic branch
$ git checkout -b feature
  ( making changes ... )
$ git commit -m "done with feature"

# It's time to fork the repo!
$ git fork
→ (forking repo on GitHub...)
→ git remote add YOUR_USER git://

# push the changes to your new remote
$ git push YOUR_USER feature
# open a pull request for the topic branch you've just pushed
$ git pull-request
Want to use all this cool stuff too? Head over to the installation instructions on GitHub.

How to contribute to an open-source GitHub project using your own fork

Serial blogger Matt Stauffer wrote a good tutorial on how use forked repos.
I just recently joined a new open source project, and there were a few folks on the team who weren't familiar with how to contribute to an open source project by forking your own copy, so I wrote this up for the docs of that project. I figured I'd also share it here. If you join a new open source project, it's very likely that you won't get direct access to push commits or branches up to the repository itself. So, instead, you'll fork the repo, make the changes on your version of the repo, and then "pull request" your changes back to the original. Here are the steps to take.

Quickly open a GitHub page from your terminal

At Spatie we use GitHub for both our client projects as our open source code. So in our day to day work we often have to open the browser to view issues of a repo or review pull requests. Paul Irish, a well known developer and part of the Google Chrome team at Google, made a nice bash script to quickly open up a GitHub page from your terminal. If you're on a path inside a git repo and type "git open" that'll open up the corresponding page on GitHub. The command also supports, amongst others, repos hosted on and Bitbucket.

Lesser known git commands

Tim Pettersen shares some of his git aliases.
Git has a strong commitment to backwards compatibility: many powerful features are hidden behind options rather than exposed as default behaviour. Fortunately Git also supports aliases, so you can create your own commands that do all manner of Git magic. Here’s a selection of the more useful (or at least entertaining) aliases defined in my .gitconfig

Git from the inside out

This essay explains how Git works. It assumes you understand Git well enough to use it to version control your projects.

The essay focuses on the graph structure that underpins Git and the way the properties of this graph dictate Git’s behavior. Looking at fundamentals, you build your mental model on the truth rather than on hypotheses constructed from evidence gathered while experimenting with the API. This truer model gives you a better understanding of what Git has done, what it is doing, and what it will do.

10 Years of Git: An Interview with Git Creator Linus Torvalds

So I'd like to stress that while it really came together in just about ten days or so, it wasn't like it was some kind of mad dash of coding. The actual amount of that early code is actually fairly small, it all depended on getting the basic ideas right. And that I had been mulling over for a while before the whole project started. I'd seen the problems others had. I'd seen what I wanted to avoid doing. The source code manager to build git was... git.

Clone your package inside the vendor directory

Dimitrios Savvopoulos, the creator of the laravel-translatable package (which I use in almost every project), shared a very nice tip on how to develop a package while it is installed as a requirement.
If you have write access to a composer package repository, you have the possibility to continue its development while it is installed as requirement in another project. Let's see how we can accomplish this. If you have another, possibly better, way to go about this, let me know in the comments.

Create a global .gitignore

Probably you're using a .gitignore file for every project. If you find yourself creating a .gitignore file for the same files on every project you should use a global .gitignore file. You can specify the location of the global .gitignore file with this command: git config --global core.excludesfile '~/.gitignore' If you're on osx you can add files such as .DS_STORE, Thumbs.db, ... PhpStorm-users could add .idea. My global .gitignore file can be viewed on github.