Git Tutorial Previously, I had committed the 3 files to local repository. Then suddently I was aware of the file List.png is committed by mistake. It would ' ve been left behind and been clean from my working directory through I get other files in local repo rather than le T 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 is removed from current snapshot in local repo and in a prev ous snapshot it ' s still here.
Don ' t worry about this your boss or buddies one day track the history of Git logs to realize that mistake and correction yo U ' ve ever made. Always remember that it's worth preserving history. Sometimes you can is blamed by the history, the sometimes you can is saved by the history. Embarrassing cannot make your get shit, being saved could be really a big deal.
For whatever reason, my boss gives me a order that all files I ' ve removed must come back immediately after somedays I com MIT the deletion for it. Let's see how 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 commit ID, just the "the" at the start could is 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 the Your boss with the finish. Let me use git log to has a look what happened just then
Figure 3.4
Instead of removing the commit from the "The history," Git figured out how to "undo the changes introduced by the specified Commi T ID (it ' s 2ee281b4 here) and appended a new commit with the resulting content.
Git Tutorial 3-scenario Extension-revert