2

I want to reorder the output of changed files in git commits so I've created a file called submodule/orderfile and configured diff.orderFile to point to that file.

Now many problems arise

  • If I add the file to .gitignore, the .gitignore will be listed as modified
  • If I add the path submodule/orderfile to .git/info/exclude the file still appears when I run git status.

Either way, orderfile or .gitignore will be listed in git status. If I commit it to a branch it'll be removed when I switch to another branch. I don't want to push those files because I only use them locally.

I tried to run git update-index --assume-unchanged orderfile like stated here but it gives

fatal: Unable to mark file orderfile

More importantly even if I can manage to ignore the file, it'll be removed when I run git clean -xdf

So how can I told git to not track the file and still leave it as-is when I run git clean -xdf?

Community
  • 1
  • 1
phuclv
  • 37,963
  • 15
  • 156
  • 475

1 Answers1

0

How about moving the file out of the repository and configuring diff.orderFile to the new path?

That was my first thought, but diff.orderFile is a relative pathname, it is treated as relative to the top of the working tree.
Maybe ../afile would work.

An alternative is to define a git wrapper script which calls git, but with the -O option when using diff.
That way, you can really place the orderfile outside the repo.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    `If diff.orderFile is a relative pathname, it is treated as relative to the top of the working tree.` I think it can work if an absolute path is used here. – ElpieKay May 22 '17 at 05:05