However, will it automatically remove these committed files from the repository?
No.
The 'best' recipe to do this is using git filter-branch
as written about here:
The man page for git-filter-branch contains comprehensive examples.
Note You'll be re-writing history. If you had published any revisions containing the accidentally added files, this could create trouble for users of those public branches. Inform them, or perhaps think about how badly you need to remove the files.
Note In the presence of tags, always use the --tag-name-filter cat
option to git filter-branch
. It never hurts and will save you the head-ache when you realize later taht you needed it
git rm --cached
(or just delete the offending files and commit), it can delete those files on checkout. Usinggit update-index --skip-worktree <files>
will remove them from being tracked directly.Ammend commits
, bring back inside the rep to its original location the folder and files moved, and push the commit.