Last updated May 19, 2013.
Tags
Tags are used for creating stable releases. To create a tag for using with the Git Drupal Repository, first, ensure that you're following the tag naming convention if you're using this tag for making a release. From inside the directory of the project, an example is:
git tag 7.x-1.0Once the tag is created, you need to push the tag up to the master repository. By itself, push doesn't send the tags up, you also need to tell it to include the tags in the push by appending the --tags flag:
git push --tagsIf you don't want to push all your tags, you can also be specific:
Example:
git push origin tag 7.x-1.0Branches
Working with branches is similar to working with tags, but branches are used for development releases. First create the new branch and check it out:
git checkout -b 7.x-2.xOnce the branch is created locally, it can be pushed up to the remote repository:
git push origin 7.x-2.xTo then work with this branch:
git checkout 7.x-2.xTo see what branches you currently have:
git branch -vThe branch with the asterisk next to it is the active branch:
% git branch -v
* 7.x-2.x 170eb10 Initial commit.
master 170eb10 Initial commit.In order for your module to work correctly with the Drupal.org testing system and supporting projects like Git Deploy, development branches should always be named using the
[Drupal version]-[Module version] pattern, never as master or develop. See here for master branch cleanup info.
Newer Git Commands
If you're running Git 1.7.0.9 or later:
When pushing a branch, you can specify -u and your local branch will be automatically set up to track the remote branch. For example:
git checkout -b 7.x-1.x
git push -u origin 7.x-1.xDeleting a tag/branch
If you mistakenly added a tag or branch, and want to remove it (assuming you haven't created a release with the tag, or committed anything to the branch), you can remove it by running the following commands.
Branch with name "branchname" (the second command is only needed if you already pushed it to the drupal.org repository):
git branch -d branchname
git push origin :branchnameTag with name "tagname" (again, the second command is only necessary if you already pushed it to the drupal.org repository):
git tag -d tagname
git push origin :tagnameIf for some reason you have a branch and a tag that are named the same (you shouldn't, but we're talking about a mistake here anyway), you can push with the following commands:
git push origin :refs/heads/branchname
git push origin :refs/tags/tagname
Comments
Master vs. Dev branches
Should there always be a version branch of a module or theme (
7.x-dev), or doesmasterdefault to the latest major version Drupal release dev branch? I believe I've seen it done both ways in contrib.Looks like naming branches
Looks like naming branches after versions is the correct way. See:
http://drupal.org/node/1076616
http://drupal.org/node/1314752
http://drupal.org/node/1395302#comment-5879482