-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_commond.txt
More file actions
30 lines (22 loc) · 1.44 KB
/
git_commond.txt
File metadata and controls
30 lines (22 loc) · 1.44 KB
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
1.分支相关
查看分支:git branch
创建分支:git branch <name>
切换分支:git checkout <name>
创建+切换分支:git checkout -b <name>
合并某分支到当前分支:git merge <name> # 上面的Fast-forward信息,这次合并是“快进模式”(用于新开分支 基于master分支 做了开发和提交,直接merge到master)
创建新commit,commit描述写入:git merge --no-ff -m "merge with no-ff" new_branch # 强制禁用Fast forward模式,Git会在merge时生成新的commit,从分支历史上就可看出分支信息
删除分支:git branch -d <name>
看到分支合并图_方法1:git log --graph --pretty=oneline --abbrev-commit
看到分支合并图_方法2: git log --graph
2.回退版本相关
查看当前仓库的提交log:git log
查看简化的log信息:git log --pretty=oneline
回退到前面第n版:git reset --hard HEAD~n
回退到前面第n版某个指定的commond ID:git reset --hard Commond ID
查看你的每一次提交命令:git reflog
3.储藏当前工作与应用储藏的工作
储藏修改: git stash # 将新的储藏推送到栈上
查看储藏: git stash list
应用储藏: git stash apply # git stash apply stash@{2} //不指定一个储藏,Git 认为指定的是最近的储藏
移除储藏: git stash drop # git stash drop stash@{2} //将要移除的储藏的名字来移除
恢复删除存储: git stash pop # git stash pop stash@{2} //恢复的同时把stash内容也删了