How do you rename a folder in git and hide it with an interactive rebase?

git, git-rebase

Solution

If it is something you haven't shared with anyone yet, which I infer that it is since you are trying to rebase it anyway, I would remove the commit that contains the renaming, and do a filter-branch.

Assuming that foo contains the first occurrence of the bad directory, and your rename is the latest commit:

git reset --hard HEAD^ # removes the rename commit
git filter-branch --tree-filter "mv bad good" foo^..HEAD

This will rename the bad directory to good.

Problem

I have a project and during the course of the project I realized I don't like the name of a directory. In GIT, we can rename the directory and then commit, but the history will still show the older folders. I would like to rebase the name change as an earlier commit. So what I would normally do is: ``` git rebase -i origin/master ``` Then shift the folder rename commit to the top. However, as expected git will yield a lot of conflicts that need to be resolved. Is there a more automated way of doing this?

Original source