git撤銷commit

請參考該文章:http://www.cnblogs.com/ningkyolei/p/5026011.htmlhtml

 

場景:git

不當心commit了一個不該該commit的修改,可是尚未push,想撤銷那個commitbash

 

命令:3d

a)git loghtm

b)git reset --hard commit_idblog

 

具體步驟以下:it

1.模擬commit一個不該該commit的修改:方法

1.1.原來的list.view.js文件im

1.2.原來的待push列表d3

1.3.按如下方法修改list.view.js文件

1.4.commit後的待push列表

2.打開git bash,並轉到對應目錄

 

3.執行命令:git log

記錄由上至下出現的第二個commit_id(d1a65e9ac9a7c4396206f0072b7fbc9138a26c1f)

4.執行命令:git reset --hard commit_id

即:git reset --hard d1a65e9ac9a7c4396206f0072b7fbc9138a26c1f 

5.再查看list.view.js和待push列表,即回到1.1和1.2的狀態

相關文章
相關標籤/搜索