I am working on a shared repository and I want to exclude all the files under certain directory just for myself.
So I made an entry in $GIT_ROOT/.git/info/exclude
/path/to/folder/
After this I removed the indexes using
git rm -r --cached /path/to/folder/*
A git status
after this show a long list of deleted file staged for commit.
I commit the changes and till here all is good as any changes made by me are not tracked by git. But I can not push the same to remote
as this will mess up other developers working repo.
After this If I pull from remote it shows me a merge conflict modified by them/deleted by us
. And with git reset --hard origin/<branch_name>
It starts tracking the folder again.
Can this not be achieved because I can not push to remote ?
A more robust solution is to:
git update-index --skip-worktree -- mysymlink
.gitignore
inside that moved folder (with a '*
' pattern).git/info/sparse-checkout
content:
*
!/path/to/mysymlink
(with mysymlink
being the name of the folder I want to ignore)
See more at "git assume unchanged vs skip worktree - ignoring a symbolic link"
The OP shshnk mentions in the comments the simpler approach:
I was able to implement it using just sparse-checkout.
Basically I mentioned the name of the folders in the format mentioned by you in.git/info/sparse-checkout
file. Nowgit
ignores the files in these folders.