5

I am trying to ignore the changes made to .gitignore file. For achieving this I am using this command git update-index --assume-unchanged bin/.gitignore on git bash.

When I execute, I see Unable to mark file bin/.gitignore response on my git bash.

How to solve this and why am I facing this problem?

I tried this link too but didn't help

git update-index --assume-unchanged returns "fatal unable to mark file"

Community
  • 1
  • 1
BeginnersSake
  • 650
  • 2
  • 18
  • 30
  • are you sure the given relative path correct? is `bin/.gitignore` file under your CWD? – Kent Feb 17 '17 at 10:25
  • @Kent Yes I have used correct path and it is under CWD. – BeginnersSake Feb 17 '17 at 10:26
  • 1
    if the path is correct, has the file already been in git stage? If it was never added, you got error too – Kent Feb 17 '17 at 10:29
  • 1
    simply, pls report the output of cmd: `git ls-files --error-unmatch /yourPath/file` – Kent Feb 17 '17 at 10:38
  • 1
    I know that doesn't help with your current problem, but if you want to locally exclude files, put their patterns into `.git/info/exclude`. That file will never be committed and is perfectly suited for telling git to ignore some files only in this work tree. – Boldewyn Feb 17 '17 at 12:17
  • Had the same problem with app.config. The filename is case sensitive. Using App.config as it was in git solved the problem. – Arjan van Dam Aug 03 '21 at 08:30

3 Answers3

9

after talking in comments and getting more information, I am posting this as an answer.

Very likely the cause is, the file you want to set assume-unchanged bit was not tracked by git. In comment, I mention the command:

git ls-files --error-unmatch /yourPath/file

Which you can check if a file is tracked by git.

If it is not tracked, you cannot update the index, since it is not indexed yet. You can just add it to your .gitignore file, so that it will be ignored by git.

Kent
  • 189,393
  • 32
  • 233
  • 301
3

Make sure your file's relative path is correct.

Try this:

$ pwd                        # see working directory 
$ ls -la ./bin/              # see if .gitignore file exist!
$ git update-index --assume-unchanged ./bin/.gitignore

And also see if your bin/.gitignore file is listed in git ls-files -o.

$ git ls-files -o    # Show other (i.e. untracked) files in the output

If .gitignore file is found then add, commit. Then try undate-index.

$ git add .
$ git commit -m 'Message'

$ git update-index --assume-unchanged ./bin/.gitignore
Sajib Khan
  • 22,878
  • 9
  • 63
  • 73
2

I think your .gitignore is untracked file. Check it using git status. If it is untracked one you won't be able to update-index for that file. Better add and commit then update-index or physically delete it and then pull the changes from your repo.