I trust that you found this blog post to be enjoyable. If you are interested in having my team handle your eCommerce setup and marketing for you, Contact Us Click here.

How to Setup Drupal Project Through Git

How to Setup Drupal Project Through Git

Git :- Git is a free open source version control system which is design to handle everything from small to very large project with speed and efficiency. Git easy very easy to and git is the world’s most popular modern version control system.

Git it is very easy to and git is the World’s most popular modern version control system.

Install Git for Linux / Ubuntu

Git is likely already installed in your unbuntu server. You can confirm this is the case on your server with the following command.

  • Then from your shell, install git using apt-get.
  • As mentioned above, you can then verifying the installation was successfully by running the following commands.
  • Now that GIT is installed on your system, this should output something lit git version 2.9.2 ( the version number might be different when you try this ).

Configuring Git

For configuring the basic GIT on a Mac, Now you have installed Git locally, you can configure your git username and email using the following commands, replacing John’s name and email address with your own.

Bitbucket Repository Setup

The next step is, to set up our code repository using Bitbucket ( you can use Githun or Gitlab or any other Git platform – the principle are the same.

  • Bitbucket Account :- If you don’t have an account yet, head over to https://bucket.org and create one. By creating an accounton gitbucket your workspace will also be created. A workspace is where you will create repositories, collaborate on your code and organise different streams of work in bitbucket account.
  • Adding an SSH key to Bitbucket :- It’s neccessary to store at least one SSH key from your local machine onto your Bitbucket account. This ensures that you system is authenticated and you can interact safely with the online repository on Bitbucket.
  • Bitbucket Project :- Every workspace that has project will have an initial project which contain all the workspace’s repository.

    Here are some points to explain how to craete a project on Bitbucket

    • Select the create button.
    • Select the project from the dropdown menu.
    • Select the workspace for the project.
    • Give a project a Name that is short and easily identifies the work your team will do in the project.
    • Note and modify the Key field.
    • Select This is a private project if you only want the project name displayed to members of your workspace.
    • Click change avatar to add or change a custom avtar.
    • Click create project.
  • BitBucket Repository :- A “create repository link” should be available on your repository page.

After filling in all the fields on the repo creation page and clicking on “create repository”.

1. Create a New Drupal Project using composer.

2. Initialize Git Repository.

3. Set up a Remote Repository.

  • Create a Remote Repository.
    • Go to GitHub, GitLab, or Bitbucket and create a new repository.
  • Add the Remote Repository.

Importing your code to Bitbucket

The “SSL” URL displayed on the repo creation configuration page above is the unique address of the new repository and it’s neccessory for cloning the repositoty locally. First of all we need to be in our local project’s directory.

We are finally ready to use Git. The folowing steps are always essential for puching our local code to the remote repository we just created :-

1. Initialising our Git project :-

All git command starts with git, followed by the action we’er after .git init is simply letting git know that this is a project we need to add version control to. Running this command inside the project’s folder will generate a .git folder in the project’s main root folder which, from now on, will contain all the git history of the project :

Even working on alone a project, we can go through the histroy of our commits and clearly see how the project and its files and folder have evolved over time.

2. Git – Staging our local files :-

This git command add all the files to our local git i.e., it make git aware of the files, the most importantly the changes in these files,that need to be tracked. In other variations git add command are possible.

3. Git – Committing our staged changes :-

The output of this commands looks like the following :-

This Git commands “Locks” our committment to pushing our changes to our remote repository. It accompained by the -m argument which is followed by an actual message.

4. Setting the remote repo URL :-

This step is only required once as it’s a first time we are attempting to push code to the online repository and local git has no idea aboutwhere is remote repository is. By running the git remote add origin {REMOTE_REPO_URL} command.

5. Git – Pushing our local changes to the remote repo:-

The Output of this command as shown the following :-

This is the last step in the sequence where our changes are actaully “transmitted” online and eventually reach our project Bitbucket repository.

This command triggers a process that makes remote project directory and its content identical to our local one i.e., all our local changes are now reflected on the Bitbucket repository with absolute precision. On Bitbucket, we can always see the codebase of our project under source.

Git branches are effectively a pointer to a snapshot of your changes. When you want to add a new feature or fix a bug - no matter how big or how small - you spawn a new branch to encapsulate your changes. This makes it harder for unstable code to get merged into the main code base, and it gives you the chance to clean up your future's history before merging it into the main branch.

Back to blog