[Git]常用命令
Git 常用命令
查看提交历史
git log
--pretty
git log --pretty=oneline -n
git log --pretty=format:"%h %s" --graph
放弃更改
-
当文件未被放入暂存区
git checkout -- <filepath> git checkout -- . -
文件已经放入暂存区
git reset HEAD <filepath> git reset HEAD . -
文件已经提交commit
git reset --hard <commitid> git reset --hard HEAD^
新建分支
git branch <name>
git checkout <name>
# 或者新建并切换:
git checkout -b <name>
变基
# 假设当前工作分支为branch2,要以branch1为基础,提交代码
git rebase branch1
git checkout branch1
git merge branch2
git push
...

浙公网安备 33010602011771号