Domanda

I have a local branch with a couple of commits. Now I need to rewrite all of those commits and change a file name but only in one specific directory. I don't want any changes to commits not on my local branch.

Running git filter-branch 'some command' master..HEAD standing in that directory gives me

You need to run this command from the toplevel of the working tree.

Of course I can run this from the top level but that would force me to write my script with the path of the directory I really want to change and eventually I would like to run the same script in a couple of directories without really knowing what there full path is.

Is there a way to run filter-branch and have the script have the current directory as it's working directory?

È stato utile?

Soluzione

No, there is not. But just make your script take a parameter and then run this in your toplevel:

git filter-branch 'yourscript the/sub/directory' master..HEAD
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top