How to uncommit files that were committed long time a ago?
Note: Since all changes in the current working directory are very important, they should not be affected!

1. Reset the repository into a committed state, but does not affect the current working directory and index(staging) tree.
git reset --soft [commit - hash]

2. Unstage all changed files
git reset HEAD --

3. Add the file you want to commit
git add [filename]

4. Add the changes into repos
git commit -m "something"

Useful command:
git log | grep Jingwei -B 5

How to reset a file into the state of a certain commit?
git checkout [commit - hash] [filename]
Note: the checkout here is quite confusing. it it requires - _ -

Open a new code review

git stash && git pull --rebase && git stash pop
post-review

Useful links:
http://git-scm.com/docs/git-reset

The theory of git rest:
http://www.tigraine.at/2010/09/15/git-unstaging-all-changes-and-reset-the-working-tree

The display lines for grep command
http://stackoverflow.com/questions/9081/grep-a-file-but-show-several-surrounding-lines

Git skills in reseting files的更多相关文章

  1. [Practical Git] Remove unnecessary git tracking with .gitignore files

    Most projects have automatically generated files or folders from the operating system, applications, ...

  2. npm run eject 命令后出现This git repository has untracked files or uncommitted changes错误

    npm run eject 暴露隐藏的文件,不可逆 结果出现下面的问题 This git repository has untracked files or uncommitted changes: ...

  3. git之删除untrack files

    退回版本 git reset --hard commit_id //不保留未提交的修改 git reset --soft commit_id //默认方式,保留未提交的修改 撤除本地没有提交的修改 g ...

  4. Git操作----删除untracked files

    # 删除 untracked files git clean -f # 连 untracked 的目录也一起删掉 git clean -fd # 连 gitignore 的untrack 文件/目录也 ...

  5. 删除git库中untracked files(未监控)的文件

    https://blog.csdn.net/ronnyjiang/article/details/53507306 在编译git库拉下来的代码时,往往会产生一些中间文件,这些文件我们根本不需要,尤其是 ...

  6. Git操作删除 untracked files

    最近使用git 管理项目的时候,编译过程中出现了很多中间文件,今天发现使用 git clean 命令可以很方便进行清除: # 删除 untracked files git clean -f # 连 u ...

  7. Force git to overwrite local files on pull 使用pull强制覆盖本地文件 转载自:http://snowdream.blog.51cto.com/3027865/1102441

    How do I force an overwrite of local files on a git pull? I think this is the right way: $ git fetch ...

  8. Git CMD - rm: Remove files from the working tree and from the index

    命令格式 git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file>…​ 命令参 ...

  9. how to force git to overwritten local files

    最佳解决方法 重要提示:如果您有任何本地更改,将会丢失.无论是否有--hard选项,任何未被推送的本地提交都将丢失. 如果您有任何未被Git跟踪的文件(例如上传的用户内容),这些文件将不会受到影响. ...

随机推荐

  1. easyui 常用代码

    最近在公司制作内部使用数据管理网页,用到了easyui,使用过程中发现与jquery的写法有比较多不一样的地方,趁现在有空,先做个笔记. (这里主要说明的是combobox的用法,其他的像textbo ...

  2. sql语句游标的写法

    当循环查找一张表的信息时,我们得写一张游标来对每条信息进行操作,具体格式如下 DECLARE @fitemid int DECLARE #point_cursor CURSORFORSELECT fi ...

  3. ASP.NET Boilerplate 邮件类使用

    在系统我们自定一个 MySettingProvider,并添加到配置集合中,定义一些邮件参数覆盖默认参数,然后通过IOC容器得到SmtpEmailSender实例,调用send方法就实现了,实现代码如 ...

  4. PHP获取文件行数

    原文出处 提供两种实现方法,但是第一种效率最好 第一种: <?php $file_path = 'test.txt'; //文件路径 此处找一个1094644行的TXT文件 test.txt $ ...

  5. 未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0[已解决]

    在使用百度UEditor,不小心将Newtonsoft.Json,升级了,然后就报的一个错,说: 其他信息: 未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0, ...

  6. shell跑一个PHP脚本的简单命令

    最近在做一个刷数据库的小功能,需要批量添加到不同的表中,写好PHP文件之后,登录到某一个服务器上面 上传文件的命令:rz 会出现一个弹框可以选择要上传的文件 执行文件并报错误的命令:/usr/loca ...

  7. JavaScript Math对象

    Math对象是JavaScript的一个固有对象,其作用是执行常见的算数任务.该对象的使用并不是像Date,Array对象使用 new关键字来得到对象,而是直接 Math.[{property|met ...

  8. 转 sqlserver字段描述相关操作sql

    可以自己查询系统表: SELECT o.name AS tableName, c.name AS columnName, p.[value] AS Description FROM sysproper ...

  9. object标签参考(转载)

    <object> 元素可支持多种不同的媒介类型,比如: 图片 音频 视频 Other 对象 显示图片 你可以显示一幅图片: <object height="100%&quo ...

  10. CentOS7下配置Openvpn 2.3.12

    1.下载安装包 #wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.09.tar.gz#wget http://swupdate. ...