Today git is a standard when we talk about version control systems. Almost every php team use git in projects. And still, we can dig for days to learn features and hidden jams.
If you do not use git, you should start right now. If you using some kind of GUI I suggest you to switch on command line interface. GUI can be easier to jump into this train, but later it will just limiting your options. With command line you can use full power and all sets of features without limit, and what is important, you will always know what you are doing in each step.
Sometimes, when we work on some features, we are adding many commits. Some of them are important, some of them are not. Let’s be honest, we make a mess, more than we want to admit.
What we do not want, is that others see our messy code, var_dumps and typo changes we fixed after feature testing in last commit left in our git log history. This is where rebase command can help us. Rebase can squash all smaller commits into one big. Result will be the same as we had just create one commit when our features is done.
Other more important squash commit benefit is that our git log will be clean. Each commit will represent one feature. Other team member do not need your commits if they represent your developments steps and/or mistakes. Nobody don’t have benefit from useless commits and pointless commit messages in log. If you find out that latest feature broke your application, you can easily go one step back. Without squashing and so many commits which are part of same last feature, how can you know to reset to previous working app state? Yea, it’s possible, but your head could explode under such a pressure.
Let’s create new feature called “ivan-jquery-show-progress” and see how rebase work in real world example. We will pretend that we work on some project and that we have a task to create a jQuery progress bar. Continue reading