I have define my .gitignore and delete corresponding files in local but they still appear in my repo.
How can I force my repo to use my local version ?
Thanks
Once the files are deleted locally (with git rm --cached
), you would still need to do:
git add -A .
git commit -m "record deletion"
git push
Then those same files wouldn't be visible anymore on your remote repo.
As Andrey Tyukin comments below, this of course does not delete the files from the history.
But it seems appropriate for files that were versioned and pushed by mistake and needs simply to be ignored.
For removing them from the history of the repo: "GitHub: Remove sensitive data".
If that does not work:
follow "How can I Remove .DS_Store
files from a Git repository?"
# remove any existing files from the repo, skipping over ones not in repo
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch
# specify a global exclusion list
git config --global core.excludesfile ~/.gitignore
# adding .DS_Store to that list
echo .DS_Store >> ~/.gitignore
Then git add, commit and push.