码迷,mamicode.com
首页 > 其他好文 > 详细

Git skills in reseting files

时间:2015-07-14 07:32:41      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:

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 - _ -

 

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

标签:

原文地址:http://www.cnblogs.com/airwindow/p/4644421.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!