【git】git撤销 add、commit、push
来源:互联网 发布:linux samba 创建用户 编辑:程序博客网 时间:2024/05/21 12:44
原文:http://blog.csdn.net/kongbaidepao/article/details/52253774
1. git add 添加 多余文件
这样的错误是由于, 有的时候 可能
git add . (空格+ 点) 表示当前目录所有文件,不小心就会提交其他文件
git add 如果添加了错误的文件的话
撤销操作
git status 先看一下add 中的文件
git reset HEAD 如果后面什么都不跟的话 就是上一次add 里面的全部撤销了
git reset HEAD XXX/XXX/XXX.java 就是对某个文件进行撤销了
2. git commit 错误
如果不小心 弄错了 git add后 , 又 git commit 了。
先使用
git log 查看节点
commit xxxxxxxxxxxxxxxxxxxxxxxxxx
Merge:
Author:
Date:
然后
git reset commit_id
over
PS:还没有 push 也就是 repo upload 的时候
git reset commit_id (回退到上一个 提交的节点 代码还是原来你修改的)
git reset –hard commit_id (回退到上一个commit节点, 代码也发生了改变,变成上一次的)
3.如果要是 提交了以后,可以使用 git revert
还原已经提交的修改
此次操作之前和之后的commit和history都会保留,并且把这次撤销作为一次最新的提交
git revert HEAD 撤销前一次 commit
git revert HEAD^ 撤销前前一次 commit
git revert commit-id (撤销指定的版本,撤销也会作为一次提交进行保存)
git revert是提交一个新的版本,将需要revert的版本的内容再反向修改回去,版本会递增,不影响之前提交的内容。
- 【git】git撤销 add、commit、push
- git add, commit, push如何撤销
- git撤销add 和 commit
- “git add” 撤销 ?还没有运行 "git commit"
- git的commit/push/add
- Git撤销git commit 但是未git push的修改
- Git撤销git commit 但是未git push的修改
- Git撤销git commit 但是未git push的修改
- Git撤销git commit 但是未git push的修改
- Git-撤销(回退)已经add,commit或push的提交
- git撤销commit,但未git push的命令
- Git的pull、add、commit、push、clone
- git命令之add,commit,push
- Git的add、commit、push命令
- git add , git commit 添加错文件 撤销
- 第四章:git add , git commit 添加错文件 撤销
- git commit & git push
- git撤销commit
- 数据库——连接查询
- Java 判断上传文件格式是否是有效的
- UNITY 跑酷学习2
- 那些问题的神回复(二)
- LPC2138的GPIO
- 【git】git撤销 add、commit、push
- 日期比较(substring split prase)
- oracle12c之 12.1.0.1.0 C 在 linux 7 上安装报错处理
- 浏览器常见错误代码
- 关于产品经理的三个文档(BRD)(一)
- Git每天都会用到的20个命令(译官网资料)
- HDU 4725 The Shortest Path in Nya Graph——建图+dijkstra
- SVN CleanUp报错
- PHP中数据类型转换的三种方式