查看commit 提交日志
$ git log
$git log --pretty=oneline
$git reflog
顯示所有提交記錄,包括已經回退的提交,如圖:提交了abc 和 bb 然后回退到 abc $git log ?只顯示abc提交 ?可以使用 $git reset --hard commit號 回退到bb
?
git reflog和git cherry-pick找回已刪除的commit記錄
git cherry-pick用于把另一個本地分支的commit修改應用到當前分支。
辦法之一: 使用?cherry-pick. ?根據git 文檔:
Apply the changes introduced by some existing commits?
就是對已經存在的commit 進行apply (可以理解為再次提交)
簡單用法:
git cherry-pick <commit id>
例如:
$ git checkout old_cc
$?git?cherry-pick?38361a68
1.?如果順利,就會正常提交。結果:
Finished one cherry-pick.
# On branch old_cc
# Your branch is ahead of 'origin/old_cc' by 3 commits.
2. 如果在cherry-pick 的過程中出現了沖突
Automatic cherry-pick failed. ?After resolving the conflicts,
mark the corrected paths with 'git add <paths>' or 'git rm <paths>'
and commit the result with:?
git commit -c 15a2b6c61927e5aed6718de89ad9dafba939a90b
就跟普通的沖突一樣,手工解決:
?
?