Git has been a reliable version control tool for a large number of closed and opensource projects. With Drupal existence an extremely collaborative opensource content management framework, a trackable, transparent and distributed version command arrangement like Git is a perfect fit. Git replaced a long-time version control partner – CVS – in early 2011 and became every Drupal contributor'southward favorite tool for its security, distributed nature, agile workflow and of course, existence opensource!
If you're a Drupal developer, you should be familiar with patches already. Patches are similar band-aids. They are small pieces of code that are added on top of already existing code files to support it or to fix whatever issues. Different types of patches include bug fixes, security vulnerability fixes, performance enhancements, styling fixes, etc. If you lot are a regular contributor to the Drupal projection, you should know that to set up an issue in Drupal cadre or contributed modules, you need to submit a patch to an issue in the issues queue. These patches are then examined and tested by the module maintainer and applied if found beneficial.
There are dissimilar means to utilise Git patch. Let'south learn more about diverse Git Unequal commands and how to create / apply a patch with the assist of git diff and git utilize. We will assume that you lot take already cloned/obtained a copy of the project in your local repository and have pulled the latest changes and so yous're not working on an older version of the project. Take a expect at some Github all-time practices here.
What does the Git Unequal command practice?
Git diff is a control used to output the changes between two sources within the git repository. The information sources can be 2 dissimilar branches, commits, files, etc.
The common utilize cases of git unequal commands are listed below.
• $ git diff
This command will output all the modified changes which are not added to git or staged.
• $ git diff filename
This will output the changes of that current file to its previous committed state.
• $ git unequal branch_name
This will output the modifications of the current branch to the mentioned branch to its previous committed state.
• $ git diff --staged path/to/file
Once the changes are added to Git or moved to staging, you will not exist able to run across the diff of the files. To see the staged changes, yous can use diff with --staged or --cached selection.
• $ git diff commit_id1 commit_id2
To see the departure betwixt whatsoever ii commits you can use this git unequal command where yous need to mention the two commit ids.
If y'all want to run into the listing of commits made in the Git repo, utilise the command $ git log. This will listing out all the commits (starting from the latest commit) along with their corresponding commit ids, the writer (developer) and the date it was committed on.
Creating a Git patch with git diff
To create a Git patch, we tin use whatever of the git unequal commands to get the changes. Nosotros then need to save the changes to a file which tin can exist used as below.
• $ git unequal > my_custom_patch_file.patch
Utilise the Git Patch
Drupal developers will want to utilise Git patches frequently to update changes or to prepare bugs. Developers will create a patch file which can exist used by other developers according to their need. To apply a git patch to the current branch use the following control.
• $ git use patch_file.patch
In the above example I take created a patch file called my_custom_patch_file.patch and I am applying that patch to my electric current branch. Later on applying a patch, you can see the modification in the status.
DOWNLOAD HERE
Posted by: wilsonthoing.blogspot.com

0 Komentar
Post a Comment