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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With