Laravel 11 Full Course 2025: Push from local to Github [Lesson #12]

Опубликовано: 17 Март 2026
на канале: codingoblin
662
16

In this video we are going to learn how to push our local Laravel application to a remote Github repository. This is a necessary step in being able to deploy our Laravel project to a live server.

Steps
The first thing you need to do is login to your Github account, if you do not have a Github account you will need to make one (https://github.com/).

Once you are logged in to your Github account we need to initialise a Git repository in our local project. This can be done by running the following command in the route of our Laravel project:
git init -b main

We now need to add the files in our local repository so they are staged for the first commit. Don't worry if this doesn't make any sense or mean anything to you. The more you do it the more it will make sense. Run the following command to do this:
git add .

We now need to commit those staged files. Do this by running:
git commit -m "First commit"

Our code is now ready to be pushed to a remote repository. We have not yet created one, so head back to your Github account. This is simply done by clicking the "Create repository" button in your Github account. Give your remote repository a name, then select if you want it to be Public or Private. We are making ours Private in this video. Make sure to leave "Add a README file" unchecked and set "Add .gitignore" to ".gitignore template: None". Submit this and you now have a remote git repository on Github!

We can now push our local repository code to our remote Github repository. But first we need to tell our local repository where it needs to push the code to. In your Github repository find the HTTPS address for your repository and copy it. You now want to run the following command in the route of your local Laravel project:
git remote add origin REMOTE-URL-COPIED-FROM-GITHUB

We now need to verify that this remote URL has been set correctly by running:
git remote -v

If it has worked you will receive a response that shows the fetch and push origins for your remote Github repository.

We can now push our local Laravel webapp repository to our remote Github repository. Do this by running the following command:
git push -u origin main

If you are using Visual Studio Code you will be asked to sign in to Github via the extension and authorize VS Code in Github. Once this is done your code will start to be pushed to your Github repository.

Once the code has been pushed to Github, go to your Github repository and refresh the page. You will now see your Laravel project files in your Github repository!

IMPORTANT
While it may look like all of the code from our local Laravel project repository is not sitting nicely in our remote Github repository, this is not the case. In our local repository is a file called .gitignore. This file contains a list of folders and files which git should ignore, or not add to our remote repository. There is one important folder in this file that we are going to remove and that is '/public/build'. This is a matter of preference, but if you are following this course we will need this removed as this is all the build files that will be needed on our live server. The reason this is a matter of preference is because it is possible to run the command to create these build files in the terminal on your live server. But we are going to do this locally instead.

Once you have removed '/public/build' from .gitignore, run the following command in the terminal to create the build files:
npm run build

Once your build files have been created we can add the files to our staging area, commit them and then push them to our remote Github repository. Do this by running the following commands:
git add *
git commit -m "Added build files"
git push

Now if you head to the /public/build/ directory in your remote Github repository you will see all of these build files that you just created locally.

Congratulations, you are well on your way to deploying your Laravel application!

Table of contents
00:00 - Welcome back
00:11 - Why push our code to Github?
00:40 - Initialise a local git repository
01:13 - Add files in local git repository
01:26 - Commit staged files
01:41 - Create remote Github repository
02:14 - Add remote origin URL to local repository
02:50 - Verify remote URL set correctly
03:06 - Push local code to remote Github repository
03:34 - View our Laravel app in remote Github repository
03:45 - IMPORTANT - .gitignore changes to add build files
04:32 - Create our build files
05:20 - Push newly created build files to Github repository

Links
https://github.com/
https://docs.github.com/en/migrations...