博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Git Tutorial 3 - Scenario Extension - revert
阅读量:6082 次
发布时间:2019-06-20

本文共 2010 字,大约阅读时间需要 6 分钟。

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

git loggit ls-tree HEADls -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.

转载于:https://www.cnblogs.com/vjianwang/p/gittutorial3.html

你可能感兴趣的文章
SIP入门(二):建立SIPserver
查看>>
Servlet3.0的异步
查看>>
WebService连接postgresql( 失败尝试)
查看>>
从头认识java-13.11 对照数组与泛型容器,观察类型擦除给泛型容器带来什么问题?...
查看>>
Python-MacOSX下SIP引起的pip权限问题解决方案(非取消SIP机制)
查看>>
从MFQ方法到需求分析
查看>>
android.view.WindowManager$BadTokenException: Unable to add window
查看>>
HDU5012:Dice(bfs模板)
查看>>
iphone openssh
查看>>
Linux下MEncoder的编译
查看>>
Javascript中闭包(Closure)的探索(一)-基本概念
查看>>
spark高级排序彻底解秘
查看>>
ylbtech-LanguageSamples-PartialTypes(部分类型)
查看>>
福建省促进大数据发展:变分散式管理为统筹集中式管理
查看>>
开发环境、生产环境、测试环境的基本理解和区别
查看>>
tomcat多应用之间如何共享jar
查看>>
Flex前后台交互,service层调用后台服务的简单封装
查看>>
MySQL入门12-数据类型
查看>>
Windows Azure 保留已存在的虚拟网络外网IP(云服务)
查看>>
修改字符集
查看>>