查看提交历史
$ git log
commit 636b4c266a6e87e557156f678c3e2c8aa1293a1f (HEAD -> master, origin/master)
Author: jackson-coder <jlxxlyh@163.com>
Date: Sat Jan 18 14:54:25 2020 +0800
third commit-相机标定+弹道拟合(上机调试成功)
commit 1c11219f21463a14250dd716d9c8bce182a806da
Author: jackson-coder <jlxxlyh@163.com>
Date: Tue Jan 14 19:43:30 2020 +0800
second commit-跟踪检测修正
commit dd45d9109b823ab5d4a624fb57abe76507abbce6
Author: jackson-coder <jlxxlyh@163.com>
Date: Sun Jan 12 16:56:49 2020 +0800
first commit
git log --pretty
$ git log --pretty=oneline
ca82a6dff817ec66f44342007202690a93763949 changed the version number
085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary test
a11bef06a3f659402fe7563abf99ad00de2209e6 first commit
$ git log --pretty=format:"%h - %an, %ar : %s"
ca82a6d - Scott Chacon, 6 years ago : changed the version number
085bb3b - Scott Chacon, 6 years ago : removed unnecessary test
a11bef0 - Scott Chacon, 6 years ago : first commit
$ git log -p //显示每次提交引入的补丁
显示每次提交引入的补丁。
%h缩写提交哈希
%an作者姓名
%ar作者日期,相对
%cn提交者名称
%ce提交者电子邮件
%cd提交日期
%cr上班日期,相对
%s学科
git log --since、git log --until
$ git log --since=2.weeks//将提交限制在指定日期之后
$ git log --since="2 years 1 day 3 minutes ago"
$ git log --since="2008-10-01"
$ git log --until=2.weeks//将提交限制在指定日期之后
其他
git log -<n> 仅显示最后n次提交
git log --author仅显示作者条目与指定字符串匹配的提交。
撤消事情
在使用git作为版本控制的时候,偶尔会出现这种情况:对当前的修改用git commit -m’xxx’做一次commit,并记录一些commit log。但是随即又因为某些原因对工程做了修改,而这次修改逻辑上属于上次的commit的内容,此时再提交一些commit显然不合适,这时候我们需要有一种命令能将本次修改的内容合并到上一次的commit中,这样本次的修改和上一次的commit中的修改就逻辑上属于同一个commit了。
$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend
恢复事件
一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除;
另一种方式是用git stash pop,恢复的同时把stash内容也删了:
$ git stash pop
On branch dev
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: hello.py
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: readme.txt
Dropped refs/stash@{0} (5d677e2ee266f39ea296182fb2354265b91b3b2a)