Dov
Dov

Reputation: 8572

After removing .gitignore, git still giving error?

In keeping with the advice from this question: Ignore files that have already been committed to a Git repository

We did the following:

git rm -r --cached .
git add .
$ git commit -m".gitignore is now working"
On branch master
Your branch and 'origin/master' have diverged,
and have 2 and 24 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
git commit -m".gitignore now works"
git pull

git says:
$ git pull
error: The following untracked working tree files would be overwritten by merge:
dir/.classpath

How do we force git to ignore the .classpath file?

Upvotes: 0

Views: 104

Answers (1)

Justin Howard
Justin Howard

Reputation: 5643

You need to commit your changes before pulling:

git rm -r --cached .
git add .
git commit -m 'Removed dir/.classpath'
git pull

Depending on the upstream commits, this could result in a merge conflict. If you get a "modified/deleted" merge conflict in dir/.classpath, you will need to remove it again before committing the merge.

git rm -r dir/.classpath
git commit # Commit the merge

Edit: Since you already committed your change, all you need to do is remove the untracked directory before pulling. You may want to make a backup first if you need the directory contents.

rm -rf dir/.classpath
git pull

Upvotes: 1

Related Questions