Check out our Angular Book Series.

How can I revert a Git directory without affecting all changes?

I have been working on a specific code change with a client for about two weeks. This included about a dozen commits to the git repository before making a pull request. The client reviewed the pull request before merging, and requested I roll back a few changes. I had made these commit 8 commits ago, and from the dozens of files changed I only had to roll back two.

How do you do it?

I didn't see an obvious way to roll back just those files using SmartGit, my tool of choice, so I had to drop back to the command line. This did it:


git checkout SHA-Value /c/path/to/repo/root/path/to/subdirectory/with/rejected/changes

The SHA is the unique identifier for each commit. I opened up SmartGit, viewed a change log, found out which commit I changed these files, went to the commit before that, clicked 'details' and the SHA value is listed right there. You can also get the SHA value from GitHub if you prefer. Go into the Pull Request, and select commits. The value is in the table, to the right of the commit message.

The path to the directory is your local system path. I had to use the absolute path. Since I'm a Windows user that started with the C drive, drilled down into my project folder, to the repository. And then I drilled down deeper into the repository to find the specific subdirectory I wanted to revert. Reverting the subdirectory is easier than reverting all the files individually.

I executed the line inside of GitShell. Everything worked.

I found a bunch of posts covering this topic, but most of them confused me. Hopefully this helps someone. Let me know!

How do I fix "Filename too long' error on SmartGit on Windows?

I've been working with a client on a project that uses AEM and ran into a problem committing code changes to their git repository. The error told me that the filename was too long.

The error was something like this:

error: unable to create file 'really long path to file' Filename too long

I banged my head on this for a bit, but eventually found a solution.

I had to change a flag with the version of Git that was included with SmartGit. Open up a console window. Move to your SmartGit install directory. For me that was:

C:\Program Files (x86)\SmartGit\

You should have a git subdirectory in there. Switch to it, and drill down into the bin directory. My full path would be this:


C:\Program Files (x86)\SmartGit\git\bin

Now run this command:


git config --system core.longpaths true

And try the commit again. Things should work fine.

All Content Copyright 2005, 2006, 2007, 2008, 2009 Jeffry Houser. May not be reused without permission
BlogCFC was created by Raymond Camden. This blog is running version 5.9.2.002.