开发中 git 几乎成了标配,git 命令使用时,必须输入 git command 方式,于是想去掉前面多余敲的字母 git, commit 即可提交,pull 即可拉代码,而不需要 git pull,所以自己就写了个脚本,用起来没发现啥问题,分享给大家,github.com/fanqingxuan/gitbin
![]() | 1 linvon 2021-03-03 19:57:47 +08:00 ![]() 你可知道有个叫 alias 的东西 |
2 leoleoasd 2021-03-03 19:59:08 +08:00 你可知道有个叫 alias 的东西 |
4 nightwitch 2021-03-03 20:13:39 +08:00 emmm,有点尴尬,这应该算 Linux 基础? alias commit = "git commit"就能完成你的工作。。 |
![]() | 5 learningman 2021-03-03 20:17:16 +08:00 楼上那个放到.bashrc,可以自动应用 |
![]() | 6 starcraft 2021-03-03 20:18:01 +08:00 via Android 我只对 log history 输出类做了条 alias,因为根本记不住。其他一直手打,没什么简化的想法。 |
7 GeruzoniAnsasu 2021-03-03 20:26:37 +08:00 ![]() |
8 zhyl 2021-03-03 21:12:07 +08:00 ![]() |
![]() | 9 Kasumi20 2021-03-03 22:12:35 +08:00 ![]() $@和$*可以快速地向下传递参数 "$@"最为常用, 不改变参数结构 "$*"则将整个参数作为一整个参数向下传递 不用""包裹的话, $@和$*都会将原先的空格稀释掉, 这可能会相当麻烦, 请务必使用"$@"和"$*" |
![]() | 10 Vegetable 2021-03-03 22:27:46 +08:00 zsh... |
12 whincwu 2021-03-03 23:19:46 +08:00 via Android zsh 有个 git 插件,gc 就是提交,gp 就是推送,等等有几十个别名可以直接用 |
![]() | 13 zzw1998 2021-03-04 07:18:18 +08:00 via iPhone ![]() 你们这下把楼主整尴尬了 |
![]() | 14 wellhome 2021-03-04 08:16:39 +08:00 via iPhone zsh 下 gc gl 。 |
15 breezeFP 2021-03-04 08:29:38 +08:00 oh-my-zsh 启用 git 插件 |
![]() | 16 jieliujas 2021-03-04 08:56:57 +08:00 vscode 自带 git 插件,鼠标点一下完事 |
![]() | 17 fyy21 2021-03-04 09:09:22 +08:00 gst ga gd 不更简单点<手动狗头> |
18 cjwfuture666 2021-03-04 09:26:10 +08:00 建议搞个人工智能,眼神识别 换个眼神就可以提交 更方便 |
![]() | 19 chiu 2021-03-04 09:31:21 +08:00 via Android ![]() 可爱 |
20 Rache1 2021-03-04 09:38:19 +08:00 你可知道,Linux 下 zsh 自带的的 alias 。 Windows 下使用 Windows Terminal + Powershell,然后在配上下面这个项目的 alias https://github.com/gluons/powershell-git-aliases/blob/master/src/aliases.ps1 需要先安装 posh-git |
21 yuanmomo 2021-03-04 09:40:54 +08:00 via iPhone gcmt,gcmtp,gp |
22 JerryChen666 2021-03-04 09:43:50 +08:00 ![]() alias cd = "rm -rf" 试试 |
23 mrleft 2021-03-04 09:44:25 +08:00 ![]() |
![]() | 24 hongch 2021-03-04 09:46:09 +08:00 楼主本来已经收获了编程的喜悦,结果..... 我给你第一个 star |
25 4kingRAS 2021-03-04 09:46:55 +08:00 重复造轮子的尴尬 |
![]() | 26 hongch 2021-03-04 09:47:33 +08:00 另外 commit 的 elif 换成 switch case 吧。。。 |
![]() | 27 shawndev 2021-03-04 09:50:56 +08:00 能记住准确命令的,去掉 git 前缀其实节约不了多少心智负担。 比如:git log --graph --decorate --oneline --simplify-by-decoration --all |
![]() | 28 karatsuba 懒是第一生产力 |
![]() | 29 collery 2021-03-04 09:53:39 +08:00 习惯了 zsh 的 git 缩减版命令,偶尔在 windows 写代码,命令得敲完整 |
30 muskill 2021-03-04 09:54:08 +08:00 楼主:别说了,别说了,好像找个地洞钻下去 |
31 smilenceX 2021-03-04 09:58:23 +08:00 为什么不用 GUI 工具,鼠标点点多轻松 |
![]() | 32 fortunezhang 2021-03-04 10:01:28 +08:00 @fxjson gl = git pull 之所以没有省略 g 是因为 g 开头的都是 git |
![]() | 33 ioudan 2021-03-04 10:04:16 +08:00 star 一下 以资鼓励 |
![]() | 34 weixiangzhe 2021-03-04 10:16:25 +08:00 zsh 开起 git 插件后, 就有好多 alias 了,还是口头支持一下楼主吧 [url=https://sm.ms/image/CZxprBFmw5AJvDM][img]https://i.loli.net/2021/03/04/CZxprBFmw5AJvDM.png[/img][/url] |
![]() | 35 gaolingyi 2021-03-04 10:22:43 +08:00 我选择 gui, 但还是支持一下楼主 |
![]() | 37 chinvo 2021-03-04 10:58:31 +08:00 谁不是从啥也不懂的新人开始的呢 |
38 adamwong 2021-03-04 11:44:35 +08:00 你可知道 sh 有 alias,git 也有 alias |
![]() | 39 Junh 2021-03-04 11:47:08 +08:00 via iPhone 我选择 GUI |
40 littlewing 2021-03-04 13:05:50 +08:00 via iPhone 你们怎么能这样,你看,楼主都不说话了 |
41 Rwing 2021-03-04 13:10:03 +08:00 你们怎么能这样,你看,楼主都不说话了 |
![]() | 42 fatestigma 2021-03-04 13:27:11 +08:00 安利一波 Emacs 插件 magit,纯键盘操作 bb = git checkout <base> bn = git branch <new> <base> cc = git commit c-ac = git commit --all pp = git push p-fp = git push --force-with-lease la = git log --all -n256 --graph --decorate 而且 stash 单行或单个 hunk 都非常方便。 |
43 xy2401 2021-03-04 13:42:01 +08:00 我对 win 上简化命令好奇。之前搜索过。没有很好的解决方案。 lz 的我看都是 bash 应该不支持 win 上 cmd 吧 |
![]() | 44 tediorelee 2021-03-04 13:46:50 +08:00 你们都是些坏人( |
![]() | 45 chen90902 2021-03-04 13:47:12 +08:00 虽然有些尴尬,但支持下楼主哈哈哈哈哈哈 |
46 brader 2021-03-04 13:55:15 +08:00 ![]() @xy2401 windows 也支持 alias 哦,我一直都是这样用的,你打开 git bash,然后 vi /etc/profile 在最下面添加 alias g='git' alias ga='git add' alias gb='git branch' alias gba='git branch -a' alias gcm='git commit -m' alias gcam='git commit -a -m' alias gco='git checkout' alias gcm='git checkout master' alias gd='git diff' alias gl='git pull' alias gp='git push' alias gst='git status' alias gm='git merge' alias gr='git remote' alias lg="log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" 你就可以愉快的使用 git 啦。 |
47 xy2401 2021-03-04 13:57:47 +08:00 git bash 已经不算 win 了吧。只是 win 上的 bash 环境 我不是 限定于 git 。就是一些 cmd 一些命令好长 想简化。但是我找过 powershell 上类似的别名 作用好像好奇怪 |
48 superrichman 2021-03-04 14:01:36 +08:00 via iPhone @xy2401 win 用 cmder,可以设置 alias |
![]() | 49 Enying 2021-03-04 14:02:28 +08:00 via Android 痛心 |
![]() | 50 paoqi2048 2021-03-04 14:09:16 +08:00 ![]() LZ:我是 |
51 brader 2021-03-04 14:27:14 +08:00 @xy2401 看个人习惯吧,反正我喜欢用 git bash,方便多了,cmd 能干的事它都能干,而且内置支持了很多小工具,和各种协议,输出又有颜色,相对于 cmd 来说,更接近 linux,用着舒服。 |
52 sherlockwhite 2021-03-04 16:07:09 +08:00 场面一度非常尴尬 |
![]() | 53 Stlin 2021-03-04 16:29:54 +08:00 zsh 有个 git 插件呀 一直都在用 |
![]() | 54 otakustay 2021-03-04 16:37:41 +08:00 alias pd="git push origin HEAD:refs/for/develop" alias pm="git push origin HEAD:refs/for/master" alias gs="git status" alias ca="git ci --amend" alias ga="git add" |
![]() | 55 ewBuyVmLZMZE 2021-03-04 16:39:26 +08:00 oh my zsh 的 git 插件一坨简化,巨好用。 |
![]() | 56 libook 2021-03-04 16:44:59 +08:00 我也有过类似的需求,所以自己做了一个 ZSH 工具箱,把常用的脚本和快捷指令都放在里面改,楼主可以参考我这个: https://github.com/libook/IdleBox/blob/master/zshrcs/public/shortcuts-git |
57 oxromantic 2021-03-04 16:47:08 +08:00 摔门而出 |
![]() | 58 lakehylia 2021-03-04 17:00:43 +08:00 gg gl hf ?魔兽对战? |
59 Suddoo 2021-03-04 18:14:12 +08:00 尴尬 |
![]() | 60 yuxi521 2021-03-04 18:55:12 +08:00 一直用的 idea 自带的 鼠标点点点 |
![]() | 61 darksword21 PRO 好单纯 |
62 sigl0p 2021-03-04 19:21:41 +08:00 一直用乌龟 GIT 的搞不清你们在说啥 |
63 b00tyhunt3r 2021-03-04 22:38:39 +08:00 这一课叫生产环境中需求才是永远滴神 |
![]() | 64 henryhu 2021-03-04 23:05:34 +08:00 oh my zsh 插件不香吗? |
66 liuy1994g 2021-03-05 09:29:42 +08:00 oh my zsh 的 ga gc gp gl |
![]() | 67 zengxs 2021-03-05 11:52:31 +08:00 除了 shell 自带的 alias 命令,git 命令本身也支持 alias git config --global alias.co checkout git config --global alias.br branch git config --global alias.ci commit git config --global alias.st status git config --global alias.last 'log -1 HEAD' 这样就可以直接用 git co 替代 git checkout 这些了,而且这些配置会直接写入 .gitconfig 文件 windows 环境下没有 bash, zsh 这些的话可以考虑这个方案 |
69 brader 2021-03-05 14:00:29 +08:00 @zengxs 还是我那个好使点,git 自带的,一定要 git 前缀,我那个利用 git bash 的 alias,可以类似 gp gl gco 这样用 |
![]() | 70 Lussac 2021-03-06 09:54:55 +08:00 @xy2401 CMD 可以直接为每一个命令写一个 .cmd 或 .bat 文件,用 %1 ~ %9 分别接收参数, %* 接收所有参数。 例如 echo @git commit -m %*> gcm.cmd 之前简单写过一个这种的 https://github.com/LussacZheng/win-alias |