Skip to content

Instantly share code, notes, and snippets.

View ephemeralrogue's full-sized avatar

FM ephemeralrogue

View GitHub Profile
ephemeralrogue /
Created April 10, 2024 20:19 — forked from wizioo/
HowTo have specific .gitignore for each git branch

How to have specific .gitignore for each git branch


My objective is to have some production files ignored on specific branches. Git doesn't allow to do it.


My solution is to make a general .gitignore file and add .gitignore.branch_name files for the branches I want to add specific file exclusion. I'll use post-checkout hook to copy those .gitignore.branch_name in place of .git/info/exclude each time I go to the branch with git checkout branch_name.