git - 将 git 别名添加到 .bash_profile 不起作用

标签 git bash

我编辑了我的 $Home .bash_profile 以包含一些 git 别名命令。我对此很陌生,我不知道出了什么问题。

.bash_profile

alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias go='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all'

alias got='git '
alias get='git '

PS1="\u$ "
alias ll="ls -lahG"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

我似乎无法理解我做错了什么。有什么想法吗?

[编辑] 只是想提一下,我添加的部分是从 PS1 开始的。例如 alias ll = "ls -lahG" 效果很好。上面的没有。

[EDIT2] 我尝试使用 gs(){ git status "$*"; } 相反,但这似乎并没有起到作用。

[EDIT3] 问题是我必须获取 ~/.profile。我最终做的是将它放在 ~/.bashrc 文件中,并根据 Sputnick 的建议获取该文件。

最佳答案

您应该使用 ~/.bashrc ~/.bash_profile 作为别名。

~/.bashrc 用于交互使用,参见 http://mywiki.wooledge.org/DotFiles & http://wiki.bash-hackers.org/scripting/bashbehaviour

最重要的是,您应该使用以下方式获取修改后的文件:

. ~/.bashrc

source ~/.bashrc

关于git - 将 git 别名添加到 .bash_profile 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12676864/

相关文章:

git - 为什么 git svn fetch 这么慢?

git - 如何在 git 中使用分支跟踪引用?

git - 自签名 SSL 证书与 Windows Server 2012、Bonobo Git 服务器一起使用

bash - 如何保持两个文件夹自动同步?

git 添加具有深度和分支选项的子模块

git - 无法将代码 checkin GitHub

linux - BASH : Filter list of files by return value of another command

linux - 如何跟踪后台运行的shell脚本?

bash - shell 更新后在 .bashrc 中找不到 shopt 命令

linux - 用 bash 设置参数