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

git st
git ci

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


当前回答

alias s="git status"

你的食指会原谅你这辈子给它带来的所有痛苦。

其他回答

对于那些希望以git别名执行shell命令的人,例如:

$ git pof

在我的终端将推动当前分支到我的原点回购:

[alias]
    pof = !git push origin -f $(git branch | grep \\* | cut -d ' ' -f2)

在哪里

$(git branch | grep \\* | cut -d ' ' -f2)

命令返回当前分支。

这是手动输入分支名称的快捷方式:

git push origin -f <current-branch>

windows的另一种可能是在一个目录中填满含有快捷方式的.bat文件。文件的名称就是要使用的快捷方式。只需将该目录添加到您的PATH环境变量中,您就可以在cmd窗口中使用所有的快捷方式。

例如(gc.bat):

git commit -m %1

在控制台中执行如下命令:

gc "changed stuff"

我添加这个作为答案的原因是,当使用这个时,你不局限于git…只有命令。

alias s="git status"

你的食指会原谅你这辈子给它带来的所有痛苦。

对我来说(我使用终端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"

在~/中添加以下行。Gitconfig在您的主目录

[alias]
# one-line log
l = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
ld = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph
ls = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative

a = add
ap = add -p
c = commit --verbose
ca = commit -a --verbose
cm = commit -m
cam = commit -a -m
m = commit --amend --verbose

d = diff
ds = diff --stat
dc = diff --cached

s = status -s
co = checkout
cob = checkout -b
# list branches sorted by last modified
b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"

# list aliases
la = "!git config -l | grep alias | cut -c 7-"

一旦完成,你可以用git a代替git add。这同样适用于别名标题下的其他命令..