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. j2ee安全介绍--转

    一.简介 现在越来越多的企业应用构建在j2ee平台上,这得益于j2ee为企业应用的开发提供了良好的框架和服务的支持.j2ee为企业应用提供了多方面的服务(Security.Transaction.Na ...

  2. [转] 学习使用:before和:after伪元素

    http://www.w3cplus.com/css3/learning-to-use-the-before-and-after-pseudo-elements-in-css.html 如果你一直密切 ...

  3. Eclipse / Android : “Errors running builder 'Android Pre Compiler' on project…”

    Errors occurred during the build. Errors running builder 'Android Resource Manager' on project 'hell ...

  4. 多目标遗传算法 ------ NSGA-II (部分源码解析) 二进制编码的个体解码操作 decode.c

    种群解码函数  decode_pop  为包装函数, 核心调用函数为  decode_ind  , 对每个个体进行解码. /* Routines to decode the population */ ...

  5. ASP.NET MVC 第四回 向View传值

    一.ViewData与TempData属性来向View页传递对象 上文中已经提到,使用ViewData可以将数据由Controller传递到View 在前文中我们建立了EiceController类  ...

  6. 使用ListView 时,遇到了 Your content must have a ListView whose id attribute is 'android.R.id.list' 错误

    今天在开发Android小应用的时候,使用到了ListView,在使用自己创建的listview风格的时候,就出现了如标题的错误提示信息,这个就让我纳闷了,以前也不会出现这个问题啊,而且也可以运行,赶 ...

  7. ORACLE解锁数据库用户

    the account is locked解决办法: 1.进入sqlplus sqlplus "/as sysdba" 2.解锁: alter user hpmng account ...

  8. java基础之抽象类与接口的区别

    在学习java的过程中,或者是在找工作笔试或面试的时候,如果你是java岗位,那么抽象类与接口的区别无疑是一个大热点,是各大公司都想要考的一个小知识点,下面是我为了9月份秋招自己总结的,若有不对的地方 ...

  9. 每天一条linux命令——login

    login命令用于给出登录界面,可用于重新登录或者切换用户身份,也可通过它的功能随时更换登入身份.当/etc/nologin文件存在时,系统只root帐号登入系统,其他用户一律不准登入. 语法: lo ...

  10. WebDriverWait 中 and, or, not用法

    1. And 用法 wait.until(ExpectedConditions.and( ExpectedConditions.visibilityOfAllElementsLocatedBy(By. ...