我如何打印我的git别名列表,即,类似于bash别名命令的东西?
当前回答
两者都很好
1 -使用Get Regex
$ git config --get-regexp alias
2 -使用清单
$ git config --list | grep alias
其他回答
这个回答是以约翰尼的回答为基础的。如果你不使用git-extras中的git-alias,它也适用。
在Linux上运行一次:
git config --global alias.alias "! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /"
这将创建一个名为alias的永久git别名,该别名将存储在~/中。gitconfig文件。使用它将列出所有的git别名,格式几乎与~/中的相同。gitconfig文件。要使用它,输入:
$ git alias
loga = log --graph --decorate --name-status --all
alias = ! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /
以下考虑因素适用:
To prevent the alias alias from getting listed as above, append | grep -v ^'alias ' just before the closing double-quote. I don't recommend this so users don't forget that the the command alias is but an alias and is not a feature of git. To sort the listed aliases, append | sort just before the closing double-quote. Alternatively, you can keep the aliases in ~/.gitconfig sorted. To add the alias as a system-wide alias, replace --global (for current user) with --system (for all users). This typically goes in the /etc/gitconfig file.
你可以在正则表达式^alias中使用——get-regexp,即所有以alias开头的配置
git config --get-regexp ^alias
这个简单的解决方法对我来说很有效
为列出别名创建一个别名:) Git配置——全局别名。别名“config——get-regexp '^alias\.'” 执行它git aliases来列出我们所有其他的aliases
你可以创建一个别名来显示你机器上的所有git别名。运行下面的代码。
git config --global alias.alias "! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /"
然后,只需运行git别名。
两者都很好
1 -使用Get Regex
$ git config --get-regexp alias
2 -使用清单
$ git config --list | grep alias
推荐文章
- 为什么git-rebase给了我合并冲突,而我所做的只是压缩提交?
- 当我试图推到原点时,为什么Git告诉我“没有这样的远程‘原点’”?
- 如何强制从另一个SSH会话分离屏幕?
- 如何从远程分支中挑选?
- 如何从终端机发送电子邮件?
- 如何查看一个分支中的哪些提交不在另一个分支中?
- 如何取消在github上的拉请求?
- HEAD和master的区别
- GIT克隆在windows中跨本地文件系统回购
- RPC失败;卷度传输已关闭,剩余未完成的读取数据
- 我应该在.gitignore文件中添加Django迁移文件吗?
- 错误:您对以下文件的本地更改将被签出覆盖
- Git rebase—即使所有合并冲突都已解决,仍然会继续报错
- 在Git中,我如何知道我的当前版本是什么?
- 跟踪所有远程git分支作为本地分支