git自定义命令使用

1.Linux~/.bashrc内容

复制代码
function custom_git {
    # 在 Windows 或 Unix 平台上设置 GIT_SSH_COMMAND
    export GIT_SSH_COMMAND="ssh -i $custom_ssh"
    git "$@"
}

# 设置 custom_ssh路径 
export custom_ssh="$HOME/.ssh/id_custom_sshkey"

2.Windows~/.bashrc内容

shell 复制代码
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi


function custom_git {
    # 在 Windows 或 Unix 平台上设置 GIT_SSH_COMMAND
    export GIT_SSH_COMMAND="ssh -i $custom_ssh"
    git "$@"
}

# 设置 custom_ssh 路径
export custom_ssh="$HOME/.ssh/custom_sshKey"

3.使用

复制代码
custom_git status
相关推荐
亚林瓜子4 小时前
git使用远程分支覆盖本地分支
git·master
我不是8神7 小时前
git知识点总结
git
Greg_Zhong10 小时前
Git建立本地与远程仓库的连接,简洁版
git·本地与远程连接
小猪咪piggy12 小时前
【工具】Git 和小乌龟安装与使用
git
二进制coder13 小时前
Git 实操:已Push的Commit能否重新Push?答案与规范全解析
git
solly79375567016 小时前
IDEA下载git项目和配置tomcat
git·tomcat·intellij-idea
拐爷16 小时前
Vibe‑coding九阳神功之夯:Git 基础操作,AI 时代的刹车系统(附速查表)
人工智能·git
嘿吖嘿嘿~17 小时前
怎么解决git@github.com出现Permission denied (publickey)的问题
git·github
岱宗夫up1 天前
Git不是工具,是协作哲学
git
生活很暖很治愈1 天前
Linux基础开发工具
linux·服务器·git·vim