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

git st
git ci

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


当前回答

如果你使用'!'操作符来生成一个shell:

aa = !git add -A && git status

这将添加所有文件,并为您提供$ git aa的状态报告。

为了方便地检查你的别名,添加这个别名:

alias = config --get-regexp ^alias\\.

然后一个快速的$ git别名会告诉你当前的别名以及它们的用途。

其他回答

这招对我很管用:

bco = "!f(){ git branch ${1} && git checkout ${1}; };f"

on:

$ git --version

git version 1.7.7.5 (Apple Git-26)

我创建了别名dog来显示日志图:

git config --global alias.dog "log --all --decorate --oneline --graph"

使用方法如下:

git dog

基本上,您只需要在~/.gitconfig中添加行即可

[alias]
    st = status
    ci = commit -v

或者你可以使用git config alias命令:

$ git config --global alias.st status 

在unix中,如果别名中有空格,则使用单引号:

$ git config --global alias.ci 'commit -v'

在windows中,如果别名有空格或命令行参数,则使用双引号:

c:\dev> git config --global alias.ci "commit -v"

alias命令甚至接受函数作为参数。看看别名。

alias s="git status"

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

在~/中添加以下行。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。这同样适用于别名标题下的其他命令..