Karen
Karen

Reputation: 2435

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

I am having the same problem as the OP on this post, but I don't understand the answer marked as correct (I don't see that it explains how to fix the situation)

I do this and get this error:

$ git update-index --assume-unchanged web.config
fatal: Unable to mark file web.config
  1. The file IS added to the repository

  2. It is NOT in .git/info/exclude

  3. It is NOT in .gitignore (it was, but I took it out, then forced web.config to be added using git add -f web.config, committed, and pushed those changes to the repo)

  4. When I do git ls-files -o it is NOT there

So what can I do to fix?

Upvotes: 193

Views: 84039

Answers (25)

adamatdevops
adamatdevops

Reputation: 11

Check that the directories aren't empty.

A lot of times git is not ignoring directories because it simply doesn't include empty directories.

Upvotes: 0

Sandeep M
Sandeep M

Reputation: 350

For anyone coming to this, do use this command. It works for windows.

git update-index --assume-unchanged ./filename.txt

Instead of providing a full path or quotes as some blogs on the internet suggested, just add a dot(.) and slash(/) before the filename to fix this. Worked like a charm for me.

Ways to ignore files in source control

Upvotes: 0

Jon Crowell
Jon Crowell

Reputation: 22338

If your path has spaces, you may get this error even if you have the casing right.

This results in the "fatal" error:

git update-index --assume-unchanged code/Solution Files/WebEssentials-Settings-json

To fix it, simply add quotes around the path.

git update-index --assume-unchanged "code/Solution Files/WebEssentials-Settings-json"

Upvotes: 5

TKF
TKF

Reputation: 638

Check that you are unignoring (--no-assume-unchanged) the file from the same path that you ran the initial ignore (--assume-unchanged) command.

I ignored the file d.txt while in path a/b/c, e.g. git update-index --assume-unchanged d.txt, but on moving to a/, I could not use git update-index --no-assume-unchanged ./b/c/d.txt, instead receiving the 'fatal: unable to mark file' message.

Upvotes: 0

noobie
noobie

Reputation: 610

For me it was because copying and pasting, the double dashes became an em dash "—assume-unchanged" instead of this "--assume-unchanged".

Upvotes: 0

Andrii Viazovskyi
Andrii Viazovskyi

Reputation: 857

stage your file, only after that run --assume-unchanged, then unstage the file

Upvotes: 3

Marc Albrand
Marc Albrand

Reputation: 19

In my case, i was getting the fatal: Unable to mark file error because i had pushed the file to my git repo, so git was not able to find it, first make sure you commit and push the template file that you want to keep in github but do not track it later.

Once pushed, now you can run the command git update-index --skip-worktree YOUR_FILE and modify it without this being tracked

Upvotes: 0

Kazeem Quadri
Kazeem Quadri

Reputation: 265

So I had this same error when I use this:

git update-index --assume-unchanged appsettings.Development.json

So I changed it to

git update-index --assume-unchanged appsettings.development.json

I actually tried many methods at first but I ended up using this. So I guess its case sensitive

Upvotes: 3

Rachel Green
Rachel Green

Reputation: 33

Had the same problem, nothing else worked (my file was tracked, and NOT in gitignore). I realised I copied the file name from terminal output a few lines above, and that made it copy the blank space AFTER the file name. Even though it looks like there is no space, I had a lot of space at the end. So copying just the file path, and keeping it in double qoutes, that helped. I also did a git reset HEAD first.

git update-index --assume-unchanged "app/src/main/java/com/username/projectName/Utils.kt"

Upvotes: 0

Ahmed Amr
Ahmed Amr

Reputation: 589

One common mistake around using this command is trying to assume either not tracked file or ignored file by git already.

Make sure first that the file is tracked by running

git ls-files | grep relative_path/to/file

If it's not showing your file, then you need to add it first:

git add relative_path/to/file

If this shows your file, or you've already added that file to git, then you should be able to run git assume commands normally:

git update-index --skip-worktree relative_path/to/file

or for folders

git update-index --skip-worktree relative_path/to/folder/

you can check if your file is assumed to be ignored by running

git ls-files -v | grep ^S

The S character represents skipped files.

Upvotes: 3

Sudeep
Sudeep

Reputation: 129

I had the same issue with cygwin in windows. Giving the full file path

Upvotes: -1

Akah
Akah

Reputation: 1398

I found that sometimes this doesn't work because you've already committed the file to your .gitignore and made a push or pull. You only need to make the push and your file should be ignored on subsequent commits even when you locally modify the file.

Upvotes: 1

Stepanov Max
Stepanov Max

Reputation: 159

In my case, I tried to use any of the methods above, but no luck.

After many attempts, I just thought to add my file to index through.

git add myfile.php

Git refused this action but he advised me to make it forcibly.

git add myfile.php -f

And that worked for me.

Upvotes: 5

chengwengao
chengwengao

Reputation: 1

Check if the file to be marked exists and spells correctly, especially the file path and file separator. The file separators of windows system and linux system are in different directions.

Upvotes: 0

Grace Aloysius
Grace Aloysius

Reputation: 131

fatal: Unable to mark file Localization/el-GR.js

What you can do is:

  1. Move to the correct path where the file is present in your local (in GITBASH)
  2. Update the index $git update-index --assume-unchanged <file name>

This helped me! :)

Upvotes: 7

Amir
Amir

Reputation: 197

For all future visitors. None of the above resolved my issue. What I realized is the .gitignore file must be placed in the right directory. In my case, once I moved .gitignore to application's root directory the issue was resolved.

Upvotes: 0

hernancortes
hernancortes

Reputation: 11

Maybe useful for someone. I had the same problem and was no syntax problem, no name with spaces, no path problem, and git reset command didn't work. I was commiting from a folder inside apache www and apache service was stopped. Started again apache service and the error is gone

Upvotes: 1

Sahil Singh
Sahil Singh

Reputation: 3787

In my case the tree I was marking was a directory, and not a file as in you case, and I was missing the forward slash after its name.

Incorrect -

git update-index --assume-unchanged directory-name

Correct -

git update-index --assume-unchanged directory-name/

Note the forward slash(/) in the end.

Upvotes: 50

bisw
bisw

Reputation: 877

Make sure the file is added to git repo, if not add the file in git repo and then try it will work.

Upvotes: 15

EdC
EdC

Reputation: 1165

I had this problem when I was trying to untrack *.orig files.

This is what I did to untrack them:

$git reset -- *.orig

if that doesn't work:

$git clean -fd

Upvotes: 1

OneSolitaryNoob
OneSolitaryNoob

Reputation: 5737

Make sure you have "web.config" checked in.

If it isn't, you will get this error message.

Upvotes: 2

Philip Oakley
Philip Oakley

Reputation: 14061

--assume-unchanged is about slow file systems, and a users promise that Git doesn't need to check this file, as Git can assume its unchanged. But some command still do check and produce 'surprise'!

Do not use on files which change.

Sorry to be the bringer of that news (I have a patch in process to change that documentation).

Upvotes: 5

methical
methical

Reputation: 131

My Problem was, that I tried the command with a * wildcard assuming it would be recursive, but it wasn't.

So what I did was

$ git reset HEAD
Unstaged changes after reset: 
M   .gradle/1.9/taskArtifacts/cache.properties.lock
M   .gradle/1.9/taskArtifacts/fileHashes.bin
M   .gradle/1.9/taskArtifacts/fileSnapshots.bin
M   .gradle/1.9/taskArtifacts/outputFileStates.bin
M   .gradle/1.9/taskArtifacts/taskArtifacts.bin

executing

$ git update-index --assume-unchanged .gradle/1.9/taskArtifacts/*

worked for me then and didn't result in OPs and my problem.

Upvotes: 4

Toby Beresford
Toby Beresford

Reputation: 1038

I was having the same issue on a Mac. Case-sensitivity wasn't an issue for me - the problem was I needed to reset my git first:

Problem:

 git update-index --assume-unchanged index.php
 fatal: Unable to mark file index.php

Solution:

git reset HEAD
Unstaged changes after reset:
M   index.php
git update-index --assume-unchanged index.php

Upvotes: 65

David Marchelya
David Marchelya

Reputation: 3432

I was having the same problem as you, and had followed the same four steps that you indicated above, and had the same results. This included the fact that my file was listed when executing git ls-files -o. However in my case, I also tried executing git update-index --assume-unchanged against a file that was not listed when executing ls-files -o, and I still received the same error "fatal: Unable to mark file".

I thought that perhaps it was a bug, and downloaded the latest version of git, but this did not help.

What I finally realized is that this command is case sensitive! This includes the full path and file name. After updating path to the directory so that the full path was specified with proper casing, the command executed properly.

Note that this was with Git for Windows, so you're results may vary with other platforms.

Upvotes: 145

Related Questions