I'm still learning git and getting the hang of it. I want to ignore files locally to my workflow only. I've read numerous Q&As on here as and as well as the git documentation, but none of them actually mention or explain how to create and access the .git/info/exclude
file in order to modify it. I don't have the file or at least it's not in the root directory of git when I call ls -la
command to see all hidden files in my local repository. I only see .git
, .gitignore
and other files seen in the repository.
There are other system files that keep showing up as modified every time I edit a file and stage it. I end up having to stash it every time to be able to commit/push to the remote repository.
I've tried using commands like nano .git/info/exclude
, cat .git/info/exclude
assuming I have to create one to make it work, but it says Error: No such file or directory
. So, how do I access the file to start ignoring them locally to make my workflow easier and less tedious?
Also, I ran the command cd .git
and I see some files within .git
directory (but no info/exclude
folder):
Note: I am aware of the git update-index --assume-unchanged <file>
and git update-index --skip-worktree <file>
as other means to ignore files locally but I'm interested in knowing how to do it with .git/info/exclude
way.
A couple things:
First, you most likely want to use .gitignore
instead of .git/info/exclude
. It does the same thing, except it gets checked into the repo and versioned along with all the working files. In most situations this would be the desired behavior.
(If you use .git/info/exclude
then only that particular clone of the repository will ignore the specified paths, and if the ignore rules change as your code evolves, then you won't have a way to keep track of which rules go with which version of your code.)
But if you really do want to use .git/info/exclude
... well, you're treating it like that's a single file name, but (per *NIX conventions, which prevail through most git docs) the /
is a path separator. So in your repo you see .git
. Then
cd .git
and if you do an ls
there you might see info
. If not
mkdir info
Then you can cd info
and create the file exclude