Git workflows with Laravel
Posted - ⚓I have my local dev box and my VPS which this site resides on. I don't want to make changes directly to the PHP code on the server, mistakes happen and that would be bad. So I write code on my dev box, and when I'm happy everything works, put the code on to the VPS. Git is a godsend for tasks like this. It also helps that Laravel is developed with Git.
First we set up a git repo on the dev box tracking the develop branch of the Laravel git repo. Then we change the origin to our own github repo, we shall call Laravel's repo upstream. Obviously we need to first go to github.com and set up a new empty repo. This means any changes we make to the code will get pushed to our repo, not Laravel's (not that we could push changes directly to them, that requires a pull request).
$ git clone -b develop git://github.com/laravel/laravel.git my-laravel
$ cd my-laravel
$ git remote rename origin upstream
$ git remote add origin git@github.com:username/my-laravel-on-github
$ git push -u origin develop
When the guys at Laravel update their code we need to incorporate those into our codebase, which is easily done.
$ git fetch upstream
$ git merge upstream/develop
Once we have made any changes we want to it is a simple case of committing and pushing those changes
$ git add <file>
$ git commit -a
$ git push -u origin develop
We also need to run the last command once we've pulled any changes from upstream. We can then pull the changes from our github repo onto the VPS. This way we can make sure nothing is going to break before we put any code in production. *[VPS]: Virtual Private Server