我看了一段录像,里面有人

git st
git ci

去工作。当我这样做时,我得到一个错误,问我是否我指的是其他东西。 作为一个新手,我想知道你要怎么做才能完成这件事?


当前回答

我在用户目录(vim ~/.profile)的.profile中添加了所有的alias命令。

alias gs='git status'
alias gp='git pull'
alias gph='git push'
alias gd='git diff | mate'
alias gau='git add --update'
alias gc='git commit -m'
alias gca='git commit -v -a'
alias gb='git branch'
alias gba='git branch -a'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcot='git checkout -t'
alias gcotb='git checkout --track -b'
alias glog='git log'
alias glogp='git log --pretty=format:"%h %s" --graph'
alias gfo='git fetch origin'

然后,我在bash和zsh shell中添加了source命令。

在bash shell (vim ~/.bashrc)中

source ~/.profile

在zsh shell中(vim~/)。zshrc)

source ~/.profile

其他回答

$ git update
git: 'update' is not a git command. See 'git --help'.

Did you mean this?
    update-ref

$ git config --global alias.update 'pull -v'

$ git update
From git://git.kernel.org/pub/scm/git/git
 = [up to date]      html       -> origin/html
 = [up to date]      maint      -> origin/maint
 = [up to date]      man        -> origin/man
 = [up to date]      master     -> origin/master
 = [up to date]      next       -> origin/next
 = [up to date]      pu         -> origin/pu
 = [up to date]      todo       -> origin/todo
Already up-to-date.

需要执行命令git config alias。在Git存储库中执行以下命令:

git config alias.ci commit

对于全局别名:

git config --global alias.ci commit

我在用户目录(vim ~/.profile)的.profile中添加了所有的alias命令。

alias gs='git status'
alias gp='git pull'
alias gph='git push'
alias gd='git diff | mate'
alias gau='git add --update'
alias gc='git commit -m'
alias gca='git commit -v -a'
alias gb='git branch'
alias gba='git branch -a'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcot='git checkout -t'
alias gcotb='git checkout --track -b'
alias glog='git log'
alias glogp='git log --pretty=format:"%h %s" --graph'
alias gfo='git fetch origin'

然后,我在bash和zsh shell中添加了source命令。

在bash shell (vim ~/.bashrc)中

source ~/.profile

在zsh shell中(vim~/)。zshrc)

source ~/.profile

可以为git和非git命令设置别名。这看起来像是在1.5版中添加的。在我的Mac 2.5.4版本上,git配置帮助页面的一个片段显示:

如果别名展开以感叹号作为前缀,则它将被视为shell命令。

例如,在你的全局.gitconfig文件中,你可以有:

[alias]
    st = status
    hi = !echo 'hello'

然后运行它们:

$ git hi
hello
$ git st
On branch master

...

对我来说(我使用终端mac)只有当我添加.bash_profile并打开另一个选项卡来加载更改时才有效:

alias gst="git status"
alias gd="git diff"
alias gl="git log"
alias gco="git commit"
alias gck="git checkout"
alias gl="git pull"
alias gpom="git pull origin master"
alias gp="git push"
alias gb="git branch"