跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 简化 git 命令
未分類
5 3 月 2021

简化 git 命令

简化 git 命令

資深大佬 : fxjson 1

开发中 git 几乎成了标配,git 命令使用时,必须输入 git command 方式,于是想去掉前面多余敲的字母 git, commit 即可提交,pull 即可拉代码,而不需要 git pull,所以自己就写了个脚本,用起来没发现啥问题,分享给大家,github.com/fanqingxuan/gitbin

大佬有話說 (70)

  • 資深大佬 : linvon

    你可知道有个叫 alias 的东西

  • 資深大佬 : leoleoasd

    你可知道有个叫 alias 的东西

  • 主 資深大佬 : fxjson

    @linvon 你是说 git alias 吗,alias 之后,貌似 git 字符不能省略吧

  • 資深大佬 : nightwitch

    emmm,有点尴尬,这应该算 Linux 基础?
    alias commit = “git commit”就能完成你的工作。。

  • 資深大佬 : learningman

    上那个放到.bashrc,可以自动应用

  • 資深大佬 : starcraft

    我只对 log history 输出类做了条 alias,因为根本记不住。其他一直手打,没什么简化的想法。

  • 資深大佬 : GeruzoniAnsasu

    https://github.com/ohmyzsh/ohmyzsh/blob/0f6aa0182c8d13a2ff909b650d790f83373dc412/plugins/git/git.plugin.zsh

  • 資深大佬 : zhyl

    https://i.loli.net/2021/03/03/KnB2txvEzPJrsXQ.gif

  • 資深大佬 : Kasumi20

    [email protected]和$*可以快速地向下传递参数

    “[email protected]”最为常用, 不改变参数结构

    “$*”则将整个参数作为一整个参数向下传递

    不用””包裹的话, [email protected]和$*都会将原先的空格稀释掉, 这可能会相当麻烦, 请务必使用”[email protected]”和”$*”

  • 資深大佬 : Vegetable

    zsh…

  • 資深大佬 : xarthur

    @starcraft 可以用 tig

  • 資深大佬 : whincwu

    zsh 有个 git 插件,gc 就是提交,gp 就是推送,等等有几十个别名可以直接用

  • 資深大佬 : zzw1998

    你们这下把主整尴尬了

  • 資深大佬 : wellhome

    zsh 下 gc gl 。

  • 資深大佬 : breezeFP

    oh-my-zsh 启用 git 插件

  • 資深大佬 : jieliujas

    vscode 自带 git 插件,鼠标点一下完事

  • 資深大佬 : fyy21

    gst ga gd 不更简单点<手动狗头>

  • 資深大佬 : cjwfuture666

    建议搞个人工智能,眼神识别 换个眼神就可以提交 更方便

  • 資深大佬 : chiu

    可爱

  • 資深大佬 : faqqcn

    你可知道,Linux 下 zsh 自带的的 alias 。
    Windows 下使用 Windows Terminal + Powershell,然后在配上下面这个项目的 alias
    https://github.com/gluons/powershell-git-aliases/blob/master/src/aliases.ps1

    需要先安装 posh-git

  • 資深大佬 : yuanmomo

    gcmt,gcmtp,gp

  • 資深大佬 : JerryChen666

    alias cd = “rm -rf” 试试

  • 資深大佬 : mrleft

    有点尴尬
    https://github.com/ohmyzsh/ohmyzsh/blob/6fbad5bf72fad4ecf30ba4d4ffee62bac582f0ed/plugins/git/git.plugin.zsh#L50

  • 資深大佬 : hongch

    主本来已经收获了编程的喜悦,结果…..
    我给你第一个 star

  • 資深大佬 : 4kingRAS

    重复造轮子的尴尬

  • 資深大佬 : hongch

    另外 commit 的 elif 换成 switch case 吧。。。

  • 資深大佬 : shawndev

    能记住准确命令的,去掉 git 前缀其实节约不了多少心智负担。
    比如:git log –graph –decorate –oneline –simplify-by-decoration –all

  • 資深大佬 : karatsuba

    懒是第一生产力

  • 資深大佬 : collery

    习惯了 zsh 的 git 缩减版命令,偶尔在 windows 写代码,命令得敲完整

  • 資深大佬 : muskill

    主:别说了,别说了,好像找个地洞钻下去

  • 資深大佬 : smilenceX

    为什么不用 GUI 工具,鼠标点点多轻松

  • 資深大佬 : fortunezhang

    @fxjson gl = git pull 之所以没有省略 g 是因为 g 开头的都是 git

  • 資深大佬 : ioudan

    star 一下 以资鼓励

  • 資深大佬 : weixiangzhe

    zsh 开起 git 插件后, 就有好多 alias 了,还是口头支持一下主吧
    [url=https://sm.ms/image/CZxprBFmw5AJvDM][img]https://i.loli.net/2021/03/04/CZxprBFmw5AJvDM.png[/img][/url]

  • 資深大佬 : gaolingyi

    我选择 gui, 但还是支持一下主

  • 資深大佬 : lhyUnited

    @collery 太真实了

  • 資深大佬 : chinvo

    谁不是从啥也不懂的新人开始的呢

  • 資深大佬 : adamwong

    你可知道 sh 有 alias,git 也有 alias

  • 資深大佬 : Junh

    我选择 GUI

  • 資深大佬 : littlewing

    你们怎么能这样,你看,主都不说话了

  • 資深大佬 : Rwing

    你们怎么能这样,你看,主都不说话了

  • 資深大佬 : fatestigma

    安利一波 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 都非常方便。

  • 資深大佬 : xy2401

    我对 win 上简化命令好奇。之前搜索过。没有很好的解决方案。
    lz 的我看都是 bash 应该不支持 win 上 cmd 吧

  • 資深大佬 : tediorelee

    你们都是些坏人(

  • 資深大佬 : chen90902

    虽然有些尴尬,但支持下主哈哈哈哈哈哈

  • 資深大佬 : brader

    @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 啦。

  • 資深大佬 : xy2401

    git bash 已经不算 win 了吧。只是 win 上的 bash 环境
    我不是 限定于 git 。就是一些 cmd 一些命令好长 想简化。但是我找过 powershell 上类似的别名 作用好像好奇怪

  • 資深大佬 : superrichman

    @xy2401 win 用 cmder,可以设置 alias

  • 資深大佬 : Enying

    痛心

  • 資深大佬 : paoqi2048

    LZ:我是

  • 資深大佬 : brader

    @xy2401 看个人习惯吧,反正我喜欢用 git bash,方便多了,cmd 能干的事它都能干,而且内置支持了很多小工具,和各种协议,输出又有颜色,相对于 cmd 来说,更接近 linux,用着舒服。

  • 資深大佬 : sherlockwhite

    场面一度非常尴尬

  • 資深大佬 : Stlin

    zsh 有个 git 插件呀 一直都在用

  • 資深大佬 : otakustay

    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”

  • 資深大佬 : syhily

    oh my zsh 的 git 插件一坨简化,巨好用。

  • 資深大佬 : libook

    我也有过类似的需求,所以自己做了一个 ZSH 工具箱,把常用的脚本和快捷指令都放在里面改,主可以参考我这个:
    https://github.com/libook/IdleBox/blob/master/zshrcs/public/shortcuts-git

  • 資深大佬 : oxromantic

    摔门而出

  • 資深大佬 : lakehylia

    gg gl hf ?魔兽对战?

  • 資深大佬 : Suddoo

    尴尬

  • 資深大佬 : yuxi521

    一直用的 idea 自带的 鼠标点点点

  • 資深大佬 : darksword21

    好单纯

  • 資深大佬 : sigl0p

    一直用乌龟 GIT 的搞不清你们在说啥

  • 資深大佬 : b00tyhunt3r

    这一课叫生产环境中需求才是永远滴神

  • 資深大佬 : henryhu

    oh my zsh 插件不香吗?

  • 資深大佬 : codehz

    @brader 缺陷:会暴力转换路径,试试在里面运行 wsl echo /mnt

  • 資深大佬 : liuy1994g

    oh my zsh 的
    ga gc gp gl

  • 資深大佬 : zengxs

    除了 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 这些的话可以考虑这个方案

  • 資深大佬 : brader

    @codehz 没理解什么是暴力转换路径呢,哈哈。我这样用了 2 年了,暂时没遇到什么问题和困扰

  • 資深大佬 : brader

    @zengxs 还是我那个好使点,git 自带的,一定要 git 前缀,我那个利用 git bash 的 alias,可以类似 gp gl gco 这样用

  • 資深大佬 : Lussac

    @xy2401 CMD 可以直接为每一个命令写一个 .cmd 或 .bat 文件,用 %1 ~ %9 分别接收参数, %* 接收所有参数。

    例如 echo @git commit -m %*> gcm.cmd

    之前简单写过一个这种的 https://github.com/LussacZheng/win-alias

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具