Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to mark file in git

Tags:

git

bash

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"

like image 343
BeginnersSake Avatar asked Dec 15 '22 00:12

BeginnersSake


2 Answers

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.

like image 52
Kent Avatar answered Dec 24 '22 13:12

Kent


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
like image 32
Sajib Khan Avatar answered Dec 24 '22 14:12

Sajib Khan