GET A QUOTE

How to use GITHUB to contribute to Drupal core or module?

Git is a leading version control system for software projects and Drupal.org uses Github for version control with it’s developers and Drupal community to build it’s core and contrib module. In this blog, I will share my experience on how to use Github to contribute code to Drupal.org.


Drupal follows git’s branches and tags for managing code. Steps and naming conventions.

 

1. A branch manages the commit code, and it moves forward automatically.

For Drupal to release naming conventions for branch first time use below naming conventions.

7.x-1.x (For Stable and dev)

8.x-1.x (For Stable and dev)

 

Below are not valid naming conventions:

7.x-1.1 (For Stable and dev)

8.x-1.1 (For Stable and dev)

 

2. Tags are used for creating releases of the project.

Below are valid naming conventions.

unstable(deprecated)             

7.x-1.0-dev1 (For dev)

8.x-1.0-dev1 (For dev)

7.x-1.0-alpha1 (For alpha)

8.x-1.0-alpha1 (For alpha)

7.x-1.0-rc1 (For dev)

8.x-1.0-rc1 (For dev)

7.x-1.1 (For Stable)

8.x-1.1 (For Stable)

 

Below are not valid naming conventions.

7.x-1.0-release1 (wrong word)

7.x-1.0-rc (doesn’t end in a digit)

7.x-1.0-UNSTABLE1 (uppercase)

 

List of command to use git for Drupal code contribution.

  1. Install GIT on the system
  2. Configure GIT using below command
    1. git config user.email “yourmailid@mail.com”
  1. After the configuration, you can clone the project using GIT command. Example below:
    1. git clone –branch 8.4.x https://git.drupal.org/project/drupal.git
  1. Go into the project directory by below command
  2. cd drupal
  3. Now check git status (Show the working tree status and check the repository status.)
  4. To check branch under this project. We have to use command git branch (Show the branch and tracking info.)
  5. To get list of tags use git tag -l (Get list all Git tags)
  6. For adding a new branch use below command
  7. git checkout -b 8.x-1.x (First create the new branch and check it out)
  8. git push origin 8.x-1.x (Once the branch is created locally, it can be pushed up to the remote repository)
  9. git checkout 8.x-1.x         (To work with this branch)
  10. For adding, a new tag use below command
  11. git tag 8.x-1.0         (First create the new tag)
  12. git push origin tag 8.x-1.0 (Once the branch is created locally, it can be pushed up to the remote repository)
  13. If you want to switch to a different branch, use below commands.
  14. git branch -a
  15. git checkout [branchname]
  16. Committing all changes locally using below commands.
  17. git add -A
  18. git commit -m “Issue #[issue number] by [comma-separated usernames]: [Short summary of the change].”
  19. Pushing the code back to the repository on Drupal.org
  20. git push -u origin [branchname]

Patching

If you haven’t cloned the repository, follow the directions above for setting up this repository in the local environment. Be sure you are on the branch you wish to patch, then ensure it is up-to-date with the following command:

git pull origin [branchname]

 

Creating a patch

For improvements, use the following command after making changes:

git diff > [description]-[issue-number]-[comment-number].patch

For more complex improvements see the Advanced patch workflow.

Applying a patch

Download the patch to the working directory. Apply the patch with the following command:

git apply -v [patchname.patch]

To avoid accidentally including the patch file in future commits, remove it after applying patch to the directory.

rm [patchname.patch]

When you’re done: Reverting uncommitted changes

Revert changes to a specific file:

git checkout [filename]

Revert changes to the whole working tree: git reset –hard

 I hope the article give you the basic information on how to use GITHUB and contribute to the Drupal.org community. cmsMinds actively participates in Drupal community and has contrib modules it maintains. Please share your feedback and let us know if we can help you as custom Drupal development company.

Leave a Reply

Your email address will not be published. Required fields are marked *

Quick Inquiry


captcha