篇首语:本文由小编为大家整理,主要介绍了如何设置Git提交注释相关的知识,希望对你有一定的参考价值。
如下步骤:
1.创建xxx_template文件,其内容为团队制定的Git提交注释规范,如:
Desgraption:
Date:
Author:
2.通过git config命令配置commit_template,如:
git config –global commit.template /d/develop/Git/Git_Home/commit_template
3.设置git commit时填写注释所用的编辑器,如:
git config –global core.editor vi
OK,设置完成,提交使用git commit会出现与下图相似的界面填写好注释才能提交成功:
参考技术A 1. 最近提交,还没有push,那么:git commit --amend这样就可以直接修改注释了。
2. push之前提交的历史注释
git rebase -i head~3
表示要修改当前版本的倒数第三次状态,这个命令出来之后,会出来三行东东:
pick f9173fc Fix wrong name "path_filename"
pick 3fddde0 Change versiton to 0.2: Add share option
pick 5962845 Change platform section name from [arch-platform-name] to [name:platform]
...
如果你要修改哪个,就把那行的pick改成edit,然后保存退出,这时候会提示
Stopped at 4c85552... Change versiton to 0.2: Add share option
You can amend the commit now, with
git commit --amend
Once you are satisfied with your changes, run
git rebase --continue
按照提示进行修改即可。
3. push 之后,已经存放到远程服务器上的修改
如果push之后,那么也可以按照上面的方法进行修改,只是提交的时候需要使用 -f 强制提交
git push -f origin master
如何在两个 Bamboo 构建之间获取 git 提交注释
【中文标题】如何在两个 Bamboo 构建之间获取 git 提交注释【英文标题】:How to get git commit notes between two Bamboo build 【发布时间】:2017-02-06 12:51:32 【问题描述】:我正在尝试使用Bamboo 为基于 Gradle 的 Android 项目设置 CI。教程here 工作非常适合成功构建。
对于下面的发行说明,我想在两个修订号之间获取 Git 日志。
git log $bamboo.repository.previous.revision.number..$bamboo.repository.revision.number
但是如何获得最后一次成功的构建 git_revision 编号和当前版本。有什么建议吗?
【问题讨论】:
【参考方案1】:这涉及编写和使用 Bamboo https://docs.atlassian.com/bamboo/REST 的 REST API [选择您正在使用的版本]
要获取所有构建结果,您需要调用:
[GET] /rest/api/latest/result/projectKey-buildKey
其中,基本路径是 http://myhost.com:8085 或 http://myhost.com:8085/bamboo结果如下:
"results": "size": 8,"expand": "result","start-index": 0,"max-result": 25,"result": [ "link": "href": "/rest/api/latest/result/projectKey-buildKey-buildNumber", "rel": "self" , "plan": "shortName": "xyz", "shortKey": "buildKey", "type": "chain", "enabled": true, "link": "href": "/rest/api/latest/plan/DS-ASVCCRED", "rel": "self" , "key": "projectKey-buildKey", "name": "ABCD", "planKey": "key": "projectKey-buildKey" , "buildResultKey": "projectKey-buildKey-buildNumber", "lifeCycleState": "Finished", "id": 198039818, "key": "projectKey-buildKey-buildNumber", "planResultKey": "key": "projectKey-buildKey-buildNumber", "entityKey": "key": "projectKey-buildKey" , "resultNumber": 45 , "state": "Failed", "buildState": "Failed", "number": 45, "buildNumber": 45 ,
如果需要 JSON 输出,只需在调用时添加 Accept=application/json 标头即可。
这将按顺序返回最新的 25 个构建结果,最新的结果是第一个。您可以查看这些结果并决定您对哪两个构建结果感兴趣。
一旦您做出决定,您就可以进行额外的调用以获取竹子为该特定构建捕获的更改集(提交详细信息)。
[GET] /rest/api/latest/result/projectKey-buildKey/buildNumber : ([0-9]+)|(latest)?expand=changes
这将为您提供如下详细的提交描述:
"changes": "size": 3, "expand": "change", "change": [ "author": "1234", "changesetId": "7f76c41a7ff48f679a91d0fa2810ef3398121dc6" , "author": "abcd", "changesetId": "104d8b7af9538599a02006005314033c8017e804" , "author": "cdef", "changesetId": "d21aef9f3745257aa501425fc31ebd0c6b33f608" ], "start-index": 0, "max-result": 3,
然后你就可以执行了
git log ...
【讨论】:
以上是关于如何设置Git提交注释的主要内容,如果未能解决你的问题,请参考以下文章