不小心本地git commit了代码怎么办

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zyjcxc/article/details/83503182

如果不小心commit了怎么办?

如果不小心commit了一个不需要commit的文件,可以对其进行撤销。


先使用git log 查看 commit日志
commit 422bc088a7d6c5429f1d0760d008d86c505f4abe  
Author: zhyq0826 <[email protected]>  
Date:   Tue Sep 4 18:19:23 2012 +0800  
  
    删除最近搜索数目限制  
  
commit 8da0fd772c3acabd6e21e85287bdcfcfe8e74c85  
Merge: 461ac36 0283074  
Author: zhyq0826 <[email protected]>  
Date:   Tue Sep 4 18:16:09 2012 +0800  

找到需要回退的那次commit的 哈希值,

git reset --hard commit_id

找到需要回退的那次commit的 哈希值,

git reset --hard commit_id

猜你喜欢

转载自blog.csdn.net/zyjcxc/article/details/83503182