0

I have an ignored file in .gitignore but I'm delete the file with:

git rm --cached myFile

And push to remote repository by mistake. When I sent pull-request its file display deleted file. I use the update-index command:

git update-index --assume-unchanged myFile

Return to me this error: fatal: Unable to mark file myFile

How to add this file repository and ignore changes?

Mesuti
  • 878
  • 1
  • 13
  • 29
  • Possible duplicate of [git: can i commit a file and ignore the content changes?](http://stackoverflow.com/questions/3319479/git-can-i-commit-a-file-and-ignore-the-content-changes) – PeeHaa Jul 01 '16 at 11:36
  • I tried this solution but it's not work for me. – Mesuti Jul 01 '16 at 11:55

2 Answers2

1

You may try editing history and removing commits from the remote (push --force). You have to ensure noone else ever got that extra commit or else you'd ask for quite a bit of trouble.

Use git rebase -i and work it out (-i means interactive). Then use git push --force to actually upload that change (--force is needed as those changed commits override old ones)

Paul Stelian
  • 1,381
  • 9
  • 27
0

Solved this problem:

  • Once should be remove the file from .gitignore file
  • Create the myFile and add to git with this command: git add myFile
  • Commit the file change: git commit -am "added myFile file
  • At least untrack the file: git update-index --assume-unchanged myFile

So now this file is not deleted from repository and ignored any changes.

Thanks for -1 reputation ;)

Mesuti
  • 878
  • 1
  • 13
  • 29