我看了一段录像,里面有人
git st
git ci
去工作。当我这样做时,我得到一个错误,问我是否我指的是其他东西。 作为一个新手,我想知道你要怎么做才能完成这件事?
我看了一段录像,里面有人
git st
git ci
去工作。当我这样做时,我得到一个错误,问我是否我指的是其他东西。 作为一个新手,我想知道你要怎么做才能完成这件事?
当前回答
$ 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
我的.gitconfig文件的PFA截图
使用以下别名
[alias]
cb = checkout branch
pullb = pull main branch
一行设置
$ 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.unstage 'reset HEAD --' && git config --global alias.last 'log -1 HEAD'
用法:
$ git st
$ git co
$ git br
$ git ci
$ git last
$ git unstage <file | dir>
一切都将变成:
$ cat ~/.gitconfig
[user]
name = Sample User
email = sample@gmail.com
[core]
filemode = false
compression = 1
quotepath = off
ignorecase = false
[color]
ui = auto
[alias]
co = checkout
br = branch
ci = commit
st = status
last = log -1 HEAD
unstage = reset HEAD --
希望能快点。
对我来说(我使用终端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"
我在用户目录(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