As we all know what’s the importance of GitHub in today’s world? we don’t have to be worried about many things in our code base if we are using github. Today we will show you how you can connect the laravel project with GitHub and start a brand new workflow.
There are a few steps that you have to follow :
Make a brand new laravel project with these simple steps you can create a new laravel project
- Composer global requires laravel/installer
- Laravel new example-app
- cd example-app
- PHP artisan serve
so these are the 4 steps to create a new laravel project.
Please follow the link below for more understanding https://laravel.com/docs/8.x/installation
Install git on your machine
Click on the below link and download the selected git for your machine as per the requirement https://git-scm.com/downloads
The page looks something like this
Make a new account on github if not already registered
Make a repository on github
In this step, we will create an empty repository in which we will going to push our laravel project
Let’s name our repository with the same name as that of your laravel project
Linking github repository with our laravel project
As you can see till now we created our private repository and also our project laravel now its time to push the code to that repository
For this, we have to follow certain steps
- Open git bash in the laravel project directory
- In git, bash enter the following commands
git initThis command will initialize the project directory of your laravel project. The git init command creates a new git repository. It can be used to convert an existing, un-versioned project to a git repository or initialize a new, empty repository.
git add .This command will add all the files
git commit -m 'initial commit'In this, we will commit the changes that we want to push
git remote add origin https://github.com:larahelp/RestApi.gitWe need to add the remote address of our laravel repository to the origin path You will get the remote address of the repository by clicking on the dropdown arrow like this.
Once the remote address is added to the origin then we have to finally push the repository by using the below command
git push -u -f origin master
After all these steps you can visit the github repository and there you can see the files of the laravel project that you pusheḍ.
That’s all we need to do to link our newly created laravel project with github.