git放弃本地add/commit

git放弃本地add/commit

  • 还未添加add的情况
  • [已经执行git add缓存了的:可以用命令](#已经执行git add缓存了的:可以用命令)

还未添加add的情况

sh 复制代码
 
 # 放弃某个文件
 git checkout <filename>
 # 放弃所有文件
 git checkout .

已经执行git add缓存了的:可以用命令

sh 复制代码
git reset HEAD filepathname (比如: git reset HEAD readme.md)

# 放弃所有
git reset HEAD . 

# 已经用 git commit 提交了的:可以用命令
git reset --hard HEAD^ 
回退到上一次commit的状态,此命令可以用来回退到任意版本:git reset --hard commitid

欢迎关注:有点建树 ,做更多交流。

相关推荐
-拟墨画扇-20 小时前
Git | 分支管理操作
git·gitee·github·gitcode
ModestCoder_21 小时前
Git 版本管理教程
大数据·git·elasticsearch
YMGogre21 小时前
Git 提交信息规范
git
charlie1145141911 天前
Git团队协作完全入门指南(下)
git
golang学习记1 天前
Facebook 为什么不用 Git?
git·elasticsearch·facebook
GIS阵地1 天前
git拉取时报错
大数据·git·elasticsearch
无限进步_1 天前
C++ Vector 全解析:从使用到深入理解
开发语言·c++·ide·windows·git·github·visual studio
charlee441 天前
Git使用经验总结9-Git提交关联到Issue
git·issue
-拟墨画扇-1 天前
Git | Bug分支操作
git·gitee·github·bug·gitcode
-拟墨画扇-1 天前
Git | Feature分支操作
git·gitee·github·gitcode