Git Tutorial 3 - Scenario Extension - revert
2015-11-13 17:28
423 查看
Git tutorial previously, I have committed the 3 files to local repository. Then suddently I was aware of the file list.png was committed by mistake. It would've been left behind and been clean from my working directory after I get other files in local repo rather than let it in. So I used git rm and git commit to correct my fault. At the end I showed the git log to explain that the list.png was removed from current snapshot in local repo but in a prevous snapshot it's still here.
Don't worry about that your boss or buddies one day track the history of git log to realize that mistake and correction you've ever made. Always remember that it's worth preserving history. Sometimes you can be blamed by history, sometimes you can be saved by history. Embarrassing cannot make you get shit, being saved could be really a big deal.
For whatever reason, my boss gives me an order that all files I've removed must come back immediately after somedays I commit the deletion for it. Let's see what can I do to rescue this fxxking situation. Take a look at below git log message and working directory to see what we get
figure 3.1
list.png is nether in the latest snapshot (see the command checked by git ls-tree) nor in working directory. Now we're going to use commad git revert to rollback the commitment of deletion with the commit ID in red rectangle.
figure 3.2
You don't need to type the full of commit ID, just the part at the start could be OK.
And then take a look at the local repository and working directory to see if list.png's come back.
figure 3.3
Seeee, it does work! Don't hurry up to report your boss with the finish. Let me use git log to have a look what happened just then
figure 3.4
Instead of removing the commit from the history, Git figured out how to undo the changes introduced by the specified commit ID (it's 2ee281b4 here) and appended a new commit with the resulting content.
Don't worry about that your boss or buddies one day track the history of git log to realize that mistake and correction you've ever made. Always remember that it's worth preserving history. Sometimes you can be blamed by history, sometimes you can be saved by history. Embarrassing cannot make you get shit, being saved could be really a big deal.
For whatever reason, my boss gives me an order that all files I've removed must come back immediately after somedays I commit the deletion for it. Let's see what can I do to rescue this fxxking situation. Take a look at below git log message and working directory to see what we get
git log git ls-tree HEAD ls -l
figure 3.1
list.png is nether in the latest snapshot (see the command checked by git ls-tree) nor in working directory. Now we're going to use commad git revert to rollback the commitment of deletion with the commit ID in red rectangle.
git revert 2ee281b4
figure 3.2
You don't need to type the full of commit ID, just the part at the start could be OK.
And then take a look at the local repository and working directory to see if list.png's come back.
figure 3.3
Seeee, it does work! Don't hurry up to report your boss with the finish. Let me use git log to have a look what happened just then
figure 3.4
Instead of removing the commit from the history, Git figured out how to undo the changes introduced by the specified commit ID (it's 2ee281b4 here) and appended a new commit with the resulting content.
相关文章推荐
- Oracle安装配置—64位Win7安装配置64位Oracle
- 如何debug看源代码
- Windbg设置条件断点
- 使用cargo自动化部署maven项目
- jquery选择器 直观实验
- 路还远
- 查找练习 hash——出现过的数字
- 安装CocoaPods以及使用CocoaPods安装AFNetworking
- 按键精灵刷阿里妈妈广告联盟源码 V1.1版
- 查看oracle 分区表
- 关闭WIN10向微软发送浏览历史
- jQuery-1.9.1源码分析系列(六) 延时对象续——辅助函数jQuery.when
- 客户端和服务端路径问题
- 我的大学之路---《大学之路》读后感
- 杭电1062 Text Reverse
- 在windows 7搭建xcode开发环境
- open函数中参数选项O_EXCL解析
- iOS QQ第三方登录
- long与double数据类型
- NSPredicate 条件查询或过虑