Git 常见操作
目录
1.git stash
2.合并多个commit
3. git commit -amend (后悔药)
4.版本回退
5.merge和rebase
6.cherry pick
7.分支
8.alias
1.git stash
git-stash操作_git stash 怎么增加更改内容-CSDN博客
2.合并多个commit
通过git bash工具交互式操作。
1.查询commit的commitID
git log --oneline
--oneline参数,代表将每个commit压缩成一行,只显示commitID和commit message的第一行。
d5ace53 第5次commit
25d5ae5 第4次commit
73c98f9 第3次commit
a50f132 第2次commit
d5d1335 第1次commit
2.变基到第一次commit,开启交互式操作。
git rebase -i d5d1335
-i 参数,代表展开交互界面
pick a50f132 第2次commit
pick 73c98f9 第3次commit
pick 25d5ae5 第4次commit
pick d5ace53 第5次commit# Rebase d5d1335..d5ace53 onto d5d1335 (4 command)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later wit