简体   繁体   中英

How to mark “release” commits in Git?

I am editing the master branch in a git repo.

Time-to-time I test a commit and find that it works well. Then I may want to mark the last of such commits as release .

It can be done with branching, but this way I need to switch branches, to merge, to switch back, etc.

Is there an easier way to mark some of master releases as the release ?

You could consider notes, as in git notes .

You can mark any commit you want with a "release" note, and move that marker (by copying and removing the old notes)

Another option - besides using mentioned git notes is to use git tag -a (it creates an annotated tag), but aliased to automate the whole process.

The following alias may be added to ~/.gitconfig :

release = !git tag -a release-$(git tag -l "release-*"|wc -l|sed 's/ //g')-$(git symbolic-ref --short HEAD)-$(git rev-parse HEAD)

It will create an annotated tag in the following form:

release-<release number>-<branch name>-<commit hash>

Note that you will be prompted to enter a tag message which cannot be empty. Of course you can customize the tag format to suit you needs. On every invocation new tag will be created. If you prefer a commit instead of a tag - it can used as well.

Also, when it comes to release process good idea is to follow git flow rules - in original version or altered to suit your needs. When working with multiple branches and releasing from master you can configure a hook that will make a release (tag, note, whatever) automatically whenever a branch is merged to master.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM