git - How to prevent losing .gitignore when checking-out older branches? -
if in master , stuff want safe git ignored, then:
git checkout <oldbranch or commit>
but old branch doesn't have ignored files arrgh! untracked files added etc , vulnerable reset --hard etc.
is there more elegant fix here other than:
git checkout master .gitignore #maybe write hook every checkout of <oldbranch or commit>?
or manage copying .gitignore .git/info/exclude
?
adding rules in .git/info/exclude
1 way, remains local workaround: won't pushed .gitignore
file would.
the best option remains create .gitignore
in checked out branch:
git checkout abranchwithoutgitignore git checkout master -- .gitignore git add .gitignore git commit -m "add .gitignore master"
then cherry-pick commit other branches.
Comments
Post a Comment