1

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

Paul
  • 1,290
  • 6
  • 24
  • 46

1 Answers1

0

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:

  • clone your remote repo locally (somewhere else)
  • 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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Remark: this does not delete the files from the history. If there is some confidential information in those files, one has to filter-branch. – Andrey Tyukin May 01 '15 at 12:07
  • it returns "nothing to commit (working directory clean)" "Everything up-to-date" – Paul May 01 '15 at 12:08
  • @Paul Did you remove the file with a simple `rm`, or with `git rm`? – VonC May 01 '15 at 12:09
  • @Paul `git clean` (http://git-scm.com/docs/git-clean) removes files which were *not* under version control. The fact that you see them in your remote upstream repo means they were versioned. What a `git status` reports? Do you see those files in the status output? – VonC May 01 '15 at 12:13
  • # On branch master nothing to commit (working directory clean) – Paul May 01 '15 at 12:14
  • can I overwrite my repo with my local version ? – Paul May 01 '15 at 12:15
  • @Paul a simple `git push` should be enough. – VonC May 01 '15 at 12:16