Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Ignore Files per Branch

Goal: only include generated files on specified branches.

Reasons:

  1. Generated files cause conflicts
  2. Deploy via Git is only option in some environments

So, in current workflow, main branch is dev, there are two deployment branches: stage and prod.

What I would expect to work is adding

build/*

[branch "stage, prod"]
    !build/*

to .gitignore or .git/info/excludes would mean that after I run rake build on dev branch, build/ does not show changed files when run git status. On stage and prod branches, build/ would show changed files.

However, all the variations I've tried of the above have not worked.

This seems like pretty typical workflow, is there some git magic I'm missing or how do people deal with this situation?

like image 780
Shae Kuronen Avatar asked May 09 '15 01:05

Shae Kuronen


1 Answers

.gitignore is a file checked into the repository like any other file. Checkout a branch, change .gitignore to how you want it for that branch, and commit it. That change will only affect that branch.

like image 106
Schwern Avatar answered Oct 02 '22 02:10

Schwern