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 init

[caption id="attachment_1049" align="aligncenter" width="617"]git-init-laravel-project Git init Laravel project[/caption]

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"

The 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.

The 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.

[caption id="attachment_1050" align="aligncenter" width="755"] Git add and Git commit on Laravel project[/caption]

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.

[caption id="attachment_1051" align="aligncenter" width="642"] Create Bitbucket empty Repo for Laravel[/caption]

 

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

Replace the repo_owner and accountname in the URL accordingly.

[caption id="attachment_1052" align="aligncenter" width="1152"]git-laravel-remote-add git remote add laravel[/caption]

Now we can go ahead and push the changes to remote repository.

git push -u origin master

[caption id="attachment_1053" align="aligncenter" width="724"]git-laravel-push-bitbucket Git push Laravel project[/caption]

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)

Comments