Quick Tip: Finding When Code Was Deleted In Your Git Repo
Several months ago I deleted a functions because we didn't think we needed it any more. Today I found out I was wrong but I couldn't remember when I deleted it or I could just check the commit and pull the function back in. In order to find the commit where the code was deleted you can use the following command:
$ git log -SfunctionNameHere
commit 60b42b9d06dc8a046d338fddf99548f056c2305c
Author: Scott Keck-Warren <warren5236@gmail.com>
Date: Sun Mar 16 11:45:41 2014 -0400
Renamed String class to StringObject
Then to see the code that was changed you can use:
$git show 60b42b9d06dc8a046d338fddf99548f056c2305c
diff --git a/PHPO/String.php b/PHPO/String.php
deleted file mode 100644
index f87926b..0000000
--- a/PHPO/String.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-
-namespace PHPO;
-
-use PHPO\ArrayObject;
<snip>
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
RSS
Top Posts
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows