假设我当前的分支是STACK-123/this-is-my-branch
。在我的.bashrc文件中,我如何运行一个函数,使提交消息成为分支名称的修改版本。假设我的别名是branch-to-commit-alias
$: branch-to-commit-alias
$: git log
Author: me
Date: <todays date>
STACK-123: This is my branch
发布于 2019-04-25 05:33:57
试试这个-
$: xmp() { git commit -m "$(git branch | sed -n '/^[*] / { s/^[*] \(.*\)/\1/; s,/,:,; s/-/ /g; p; }') $@"; }
然后,您可以像使用提交一样使用它。
$: xmp
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
$: touch foo
$: git add foo
$: xmp
[master ac63834] master -
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 foo
$: git rm foo
rm 'foo'
$: xmp testing
[master ade608b] master - testing
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 foo
$: git log
commit ade608b32e45d586e6a72275939df12f4f50ee11 (HEAD -> master)
Author: Paul Hodges <Paul.Hodges@charter.com>
Date: Wed Apr 24 16:29:56 2019 -0500
master - testing
commit ac638346981b3104cb5185d5240fe218e827504a
Author: Paul Hodges <Paul.Hodges@charter.com>
Date: Wed Apr 24 16:29:33 2019 -0500
master -
不过,我会选一个更好的名字。;)
https://stackoverflow.com/questions/55838261
复制相似问题