I have a git repository hosted on Github. After committing many files, I am realizing that I need to create .gitignore and exclude .exe, .obj files.
However, will it automatically remove these committed files from the repository? Is there any way to force that?
No you cannot force a file that is already committed in the repo to be removed just because it is added to the
.gitignoreYou have to
git rm --cachedto remove the files that you don’t want in the repo. ( –cached since you probably want to keep the local copy but remove from the repo. ) So if you want to remove all the exe’s from your repo do(Note that the asterisk * is quoted from the shell – this lets git, and not the shell, expand the pathnames of files and subdirectories)