# Git日常使用笔记(持续更新...)

# 个人常用配置 .gitconfig

[user]
	name = cpp #用户名
	email = cpp@cpp.com #邮箱
[http]
	SSLVerify = false #不验证SSL证书
[alias] 
	#缩写
	mg = merge
	st = status
	sw = show
	ci = commit
	co = checkout
	br = branch
	ss = status -s
	mg = merge
	mt = mergetool
	cf = config
	line= log --oneline
	lst = log --stat
	cdf = clean -df
	resf = reset --soft
	rst = reset
	rehead = reset HEAD
	pr = pull -r
	unstage = reset HEAD

[credential]
	helper = store #凭证缓存方式,这里设置为store,表示使用本地缓存。
[core]
	editor = vim #设置编辑器为vim
	quotepath = false #不对路径进行转义
[merge]
	tool = meld #合并工具为meld
[diff]
	renames = true #在diff中显示重命名的文件
	tool = meld #diff工具为meld
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

# branch 分支操作

# 基础操作

git branch #查看当前的分支
git branch -v #查看当前的分支与远程分支
git branch -vv #查看当前的分支与远程分支,可以看到对应的上游分支
git branch -rv # 即--remote查看远程分支
git push [remote_name] [local_branch]:[remote_branch] #推送local_branch本地分支到远程仓库remote_repo的分支remote_branch
git push [remote_name] --delete [remote_branch] #删除远程仓库remote_repo的分支remote_branch
1
2
3
4
5
6

# 查看分支从何处打出

# git reflog show <分支名>
boys@VM-20-6-ubuntu:~/opensource/menu$ git reflog show master #查看master出处
3580d3c (HEAD -> master, tag: V3.1.0_R, origin/master, origin/HEAD) master@{0}: clone: from https://gitee.com/const-zpc/menu.git
1
2
3

# commit 提交操作

提交遗漏时,使用 git commit --amend追加提交到上次的commit

git add xx #要追加提交的内容
git commit --amend #追加提交.
1
2

# clean 清除

最近更新: 5/4/2023, 6:45:27 PM