getting an old file in git from a directory than no longer exists

Main menu:


Recent Posts


RSS Feed RSS - Posts

September 2016
« Aug    

Past Posts

Java/Java EE



getting an old file in git from a directory than no longer exists

September 24th, 2016 by Jeanne Boyarsky

Some time ago, I had deleted a file in git along with renaming the directory it was in. I had wanted to rename the file rather than delete it. So now I needed it back. This took a few steps so I decided to blog what I did.

Step 1 – find the command to get the commit number for my deletion

I had no idea how to do this so I googled it. A comment on this post was really helpful. On OSX, I ran:

git log --diff-filter=D --summary | sed -n -e '/^commit/h' -e '\:/:{' -e G -e 's/\ncommit \(.*\)/ \1/gp' -e }

While I understand this, I never would have thought to write it.

This gave me a list of all my commits. Then I added | grep myFileName to it and I got the commit where this file was deleted.

Step 2 – Look at commit details

Next I did a git show to see whether it was me or my teammate that

git show myCommitId

It was me. I didn’t know that at the start. Oops!

Step 3 – Retrieve the file

It is possible to do a git checkout of just one file. However the folder structure doesn’t exist anymore in the latest, so this would be a pain. I decided to just get the file from the github UI. I ran the following (with real values for myRepo and myCommitId).

Then I viewed and downloaded it. Yay. My image file is back.

Step 4 – Commit again

I renamed the file again and added/committed normally.

Done! It’s now like this mistake never happened. Except in git history!

the successor to sysdeo (and mongrel) for launching tomcat from eclipse

August 27th, 2016 by Jeanne Boyarsky

I’ve been using Mongrel to launch Tomcat in one click from Eclipse. In Neon, this stopped working. I learned in a comment on that blog post that there’s now a plugin called “Eclipse Tomcat Plugin 9.1.0” that does the same thing. It is advertised as being a successor to Sysdeo. And it is. But so was Mongrel. However, it works in Neon and does the same thing as Sysdeo/Mongrel so it is logically a successor to both!

The process was easy to get going:

  1. Uninstall Mongrel
  2. Restart Eclipse
  3. Install Eclipse Tomcat Plugin 9.1.0
  4. Restart Eclipse
  5. Preferences
  6. Tomcat  – choose version of Tomcat path and Tomcat home

That’s it!

Turning off SonarLint for a project in Eclipse

August 20th, 2016 by Jeanne Boyarsky

Overall, I like using SonarLint in Eclipse. When I’m doing something like working on the CodeRanch forums, being informed of possible problems is great. When working on mock exam questions, not so much. Mock exam questions have lots of System.out.println statements. They also have a variety of poor coding practices for anywhere other a certification exam.

Luckily, turning off SonarLint for a project is a simple two part operation.

Part 1 – Turn off Sonar Lint for the project

  1. Just go to the project preferences and choose SonarLint.
  2. Then uncheck “Run SonarLint” automatically.

If you have the foresight to do this before you’ve opened any files in the project, you are done. If not, there is part 2.

Part 2 – Delete any issues thus far

  1. Open the SonarLint Issues view.
  2. Select all. (Ctrl-A is your friend).
  3. Right click and choose Delete.
  4. Choose yes when asked if you are sure.

That’s it. I’m glad I ddi this. Less than a couple of minutes of effort and now I don’t have blue squiggles in all my mock exam stuff!