Setting up Laravel project with Git

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Efficient Laravel Project Management with Git Collaboration Body:

Setting up a Laravel project with Git allows you to manage your application development process in an organized and scalable manner. By working together with the main project's updates, you can ensure that your project remains up-to-date while also contributing back to the community. In this blog post, we will walk you through the step-by-step commands to set up your Laravel project with Git and collaborate seamlessly.

1. Configuring Your Local Environment

To begin, make sure you have installed Laravel on your local machine. Follow the official Laravel setup guide to initiate a new project and ensure that it's working properly.

2. Initialize Git Repository

With your Laravel project running smoothly, it is time to initialize the Git repository. Navigate to your project folder and run the following command:

```bash git init ``` The above command creates a hidden directory named `.git`, which contains all the necessary files and folders for version control with Git.

3. Add Local Repository to Remote Origin

Next, go to Laravel's official repository, click on the "Use this template" button, and follow the instructions to create a new fork of their project in your GitHub account. This will serve as the remote origin for our project.

4. Sync Local Repository with Remote Origin

Now that you have created a remote origin, you need to add it to your local repository and fetch the latest updates from the main project. Run the following commands:

```bash git remote add upstream https://github.com/laravel/laravel.git git fetch upstream master git checkout master -b mine-master ```

5. Push Local Changes to Remote

With your local master branch created, you can now push any changes made in your project to the remote repository for sharing and collaboration. To do this:

```bash git add . git commit -m "My custom work" git push origin mine-master ```

6. Merge Updates from Remote Origin

Keep your local repository up-to-date with the latest updates from the main project by merging changes from the remote origin's master branch into yours. You can achieve this using the following commands:

```bash git pull upstream master --rebase git merge development -m "Merged updates from Laravel/Laravel" ```

Conclusion

By following these steps, you are now well on your way to managing your Laravel project efficiently with Git. Regularly re-evaluate the state of your local repository and main project, ensuring that your custom work remains compatible with the latest updates from the community. Remember to keep your remote origin up-to-date by periodically pushing changes back to it. For more detailed guides and best practices on Laravel development, visit our blog at LaravelCompany Blog.