Make .gitignore ignore everything except a few files

An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources. # Ignore everything * # But not these files… !.gitignore !script.pl !template.latex # etc… # …even if they are in subdirectories !*/ # … Read more

How do you fix a bad merge, and replay your good commits onto a fixed merge?

Please don’t use this recipe if your situation is not the one described in the question. This recipe is for fixing a bad merge, and replaying your good commits onto a fixed merge. Although filter-branch will do what you want, it is quite a complex command and I would probably choose to do this with … Read more