Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skovmand's avatar

L5-upgrade: Squashing commits to preserve file history

Hi everyone.

I need help figuring out which git commit to squash to preserve the file history from my L4.2->L5 upgrade.

I mean the Git rebase -i recommendation in the blog post by Matt Stauffer, where he writes "If you did the commits along the way like I did, you can squash them together to get continuity with git squash. Run git log to see how many commits you used; I used 3. Then run git rebase -i HEAD~3 (replace 3 with your number.)" (http://mattstauffer.co/blog/upgrading-from-laravel-4-to-laravel-5)

My git rebase file looks like this.

pick d9aaf19 LitteratureTest for Teachers (Here I use L4.2)
pick 1f31325 Delete everything before upgrading to L5 (First commit in upgrade)
pick 885d304 Bring in Laravel 5 base.
pick ea5cefa Rewriting the exception handler. Not done yet...
pick 55122aa Working on testing.

Which commit should I squash to preserve the history from d9aaf19 to 885d304?

Thanks!

0 likes
3 replies
skovmand's avatar

Am I right in thinking I should squash all the L5-commits together, so there is only one L5 commit? That is, write squash for the bottom four ones, which will then be merged with 1f31325.

lihaibh's avatar

@skovmand Um im in the same situation, i "git squashed" all the commits since and include "Delete everything before upgrading to L5" to the bottom, but when i checked a file in the database migration folder i couldnt find it's history except the last "git squash" commit on it... I dont understand how git suppose to know where the new files are.

Now that we are in L5 and the directory structure changed, database migrations located in database/migrations rather than app/database/migrations. How git will know to associate files in the previous version to the new version. assume i have file 1.php in app/database/migrations, now i added 1.php in database/migrations and i added also 1.php in "blabla" folder, why git will choose the "database" directory and not the "blabla" directory regarding the 1.php file?

Anyway it doesnt work for me =\

lihaibh's avatar

Edit: in order that git squash will work and save continuity of file history. After you remove the files you need to deliver the files from your old laravel 4 app to the right place in your new laravel 5 app.

Additionally, in order that git will know that a file change its location you need that the removed file and the file added in the new location will have the same name and also same content, you should not transfer the files make adjustments and than commit them, you should transfer the files commit them and then make adjustments and commit again, the first step is important in order to save the continuous of changes of files..

Please or to participate in this conversation.