问题
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.gitignorewill be listed as modified - If I add the path
submodule/orderfileto.git/info/excludethe file still appears when I rungit 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?
回答1:
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.
来源:https://stackoverflow.com/questions/44104238/how-to-properly-handle-a-file-only-used-locally-in-git