MoMa
MoMa

Reputation: 21

Remove multiple instances of files from Git source control

I'm using Visual Studio Community 2017 and have just migrated all my repos from VisualSVN to Git. Because branches are seperate folders in SVN, in Git those branch folders now contain seperate copies of the code. As part of cleaning the git repo up I want to remove all instances of certain files, such as app.config (which should never have been there anyhow), across all folders in the git repo.

How can I remove all instances of a app.config no matter where in the folder structure it is. I know that

git rm --cached <file name>

can remove a single file, but how can I search over the entire repo to remove all instances of that file?

Upvotes: 0

Views: 107

Answers (1)

Mureinik
Mureinik

Reputation: 312106

I'm not aware of a way to do this in git alone, but some shell scripting this should make it possible:

$ find . -name <file name> -exec git rm --cached {} \;

Upvotes: 1

Related Questions