Reputation: 7799
I created a git repo:
mkdir ~/configs
cd ~/configs
git init
git config core.worktree "../../"
echo "*" > .gitignore
But files are not ignored:
git status
Sur la branche master
Validation initiale
Fichiers non suivis:
(utilisez "git add <fichier>..." pour inclure dans ce qui sera validé)
../.ICEauthority
../.Skype/
../.VirtualBox/
[...]
How ignore files when use git config core.worktree
?
Upvotes: 1
Views: 956
Reputation: 308
From the git documentation for gitignore:
- Patterns read from $GIT_DIR/info/exclude.
So all you need to do is treat the "info/exclude" file like it's a .gitignore
file at the root of your worktree.
Upvotes: 0
Reputation: 3633
Your .gitignore file will work better at the root of your git work tree.
Consider..
echo "*" > ../../.gitignore
When you are separating your git-dir and work-tree, I normally recommend you create a bare
git repo, though this can make it seem more complex.
Also consider the following instead of using .gitignore.
# git config status.showUntrackedFiles no
# git config status.relativePaths false
The showUntrackedFiles=no
tells git to report only on changes to tracked files, and not untracked files. It also removes the need to use -f
every time you feel a need to add a new file to the repository. Another advantage is you can override the showUntrackedFiles
setting on the fly with git status -u
.
The relativePaths
option is handy (I find). git status will use absolute paths when reporting file status. Since the working directory is outside the git directory, I find this to be a clearer view of what has changed.
Lastly, when you want to do commits, you will find you have to keep using CD to go to the git directory. Try
# export GIT_DIR=/path/to/.git
# git status
To avoid having a fixed GIT_DIR
in my shell environment, I normally wrap this in an alias so the GIT_DIR
is only set for the specific instance of git
;
# alias gitc='GIT_DIR=/path/to/.git git'
# gitc status
This will allow you to manage the git repository from anywhere, even outside the work tree. It also works extremely well with the bare
repository I referred to above.
HTH
Upvotes: 4