inShare Being a powerful and flexible version control system, Git provides great functionality over such legacy centralized tools as CVS and Subversion. But this great number of options for workflow can sometimes make it difficult to decide on the best way to commit your code to the project. The following guidelines are useful for the majority of software projects in a Git repository. While not applicable to each Git project, they can ensure your own project eventually accumulates some reasonable repository history. Keep your commits small and logical Mind the following tips on commit size for your Drupal project. Always update and add a module in its own commit. Avoid bundling multiple modules of the same commit if there is no tight coupling between them. Write API-level functions and commit them prior to writing and committing those functions’ consumers. Write phpdoc comments and first when creating a new module. After this fill each function out committing it along the way. Commit bug fixes not related to your branch in separate commits or a separate commit of a new branch. If your commit has over 100 code lines, re-evaluate it for logical changes. Always review your code before committing Reviewing explicitly what needs committing seems the best method of the commit process. Git offers a great tool for this: ‘git add –patch’ The command shows all changes in the code and asks whether they are to be committed. Avoid rebasing shared commits Rebasing shared commits needs a “forced push” which automatically invalidates all work other people might be doing on this branch of code. Thus, it obscures a branch’s actual web development history for the sake of Git history’s arbitrary cleanliness. Always store unmerged remote branches A serious difference between Subversion and Git is a branch in Git is only a pointer to commits and the commits not attributed to any branch are eventually to be removed in the process of garbage collection. While in Subversion deleted branches may be restored by merely checking out some old revision. So, if you need to easily handle obsolete branches to reference them if needed, refer to ‘git merge’ commands with parameters ‘-s ours obsolete-branch’ and ‘-s ours edit obsolete-branch’ Make Git your toolbox Git is easy to extend and configure. It allows for adding custom commands and writing absolutely new commands of top levels in any language. You can simplify common Git workflows and commands with multiple extensions which are easy to search on GitHub and Google. These guidelines are the most common tips you should use to organize and manage your projects in Git.