# git 配置基本命令
配置
~/.gitconfig里的[alias]可以配置别名
[alias]
a = add
amend = commit --amend
c = commit
ca = commit --amend
ci = commit -a
co = checkout
d = diff
dc = diff --changed
ds = diff --staged
f = fetch
loll = log --graph --decorate --pretty=oneline --abbrev-commit
m = merge
one = log --pretty=oneline
outstanding = rebase -i @{u}
s = status
unpushed = log @{u}
wc = whatchanged
wip = rebase -i @{u}
zap = fetch -p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
缓存一个仓库的用户名和密码
git config --global cendential.helper cache
git config --global cendential.helper 'cance --timeout=3600'
1
2
2
分支常用的功能:
- 查看分支的合并与非合并情况 --merged --no-merged
- 删除本地分支 -d
- 远程仓库名/分支名
- 删除远程分支 git push origin :branch1
# 之前提交,忽略某些提交文件,之后不再提交
- git update-index --assume-unchanged file
- git update-index --no-assume-unchanged file
- git rm --cached -r -n 将文件从暂存删除
- git checkout <tree-ish> <files> 或 git checkout HEAD^ file 恢复到之前版本
- git log --stat --diff-filter=D 文件在哪些被删除了
- git reset HEAD file 把文件还原?
# 过程,及返回上一步
- untracked 未跟踪 ---> add,可以开始跟踪
- no stage 跟踪未暂存 ---> add,放入暂存区 相反:git rm file(--cached); git mv
- commit
- push
- git diff file file 变化
# 文件跟踪
- 文件重命名:git mv --force oldName newName
- 从git 删除,但保留文件:git rm --cached filename