Upload Laravel Project to Git
So you are now ready with your Laravel Application and you are looking forward to upload laravel project to git (bitbucket) to share it with your teammates or clients.
This article will explain you how you can convert your existing project to a git project and then upload laravel project to git (remote) repository (Bitbucket for this article)
Before we continue make sure you have a Laravel Project ready and also git install on your system. Make sure the git command works on your terminal or command prompt.
Let’s continue with the steps.
Convert your Project to a Git Project
Open your terminal and navigate to the project root directory and run the git init command.
Git Add and Commit All Files
With the git init command we have successfully converted our project into a local git project. Although we have not yet added a git remote to our project.
As a second step lets go ahead and add and commit all the files to our local git repository.
Run the git add and git commit command on the project root.
git add . git commit -m "First Commit"
git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit.
git commit command commits the staged snapshot to the project history. Committed snapshots can be thought of as “safe” versions of a project—Git will never change them unless you explicitly ask it to.
Create a New BitBucket Repository
We are now ready to push our changes to a remote repository. But before that we have to create a repository where we can push our changes.
Login to Bitbucket if you already have an account or SignUp for a new account. On the left hand menu , Click on the + symbol to get the option of Creating a New Repository.
Enter a suitable project name and click on Create Repository. A blank repository will be created and you will be redirected to the overview page of the repo.
Now we can go ahead and make this repo our remote repo for the laravel project.
Add Remote Repo and Push Changes
To add the repository you just created as the remote repo for your local laravel project. Run the following command on your project root in terminal.
git remote add origin https://<repo_owner>@bitbucket.org/<accountname>/<reponame>.git
accountname in the URL accordingly.
Now we can go ahead and push the changes to remote repository.
git push -u origin master
If you see at source in your bitbucket repository. You should see your Laravel directory structure along with the files.
That’s all is required to upload laravel project to Git (Bitbucket)