Separate files in Git

I’m trying to keep my static files in a separate branch so that I can keep them from merging into my master brach (on Heroku, your application’s slug needs to stay small). I don’t want to ignore my static files, because I want to keep them inside my “devel” branch.

Ideally I’d like to keep test.db blank and my entire public folder blank in the master branch.

  • git branch naming best practices
  • Is there any way to exclude branches from showing in GitK?
  • How to handle dependencies when using git topic branch workflow?
  • Is it safe to directly delete head files from .git?
  • git / gerrit prevent develop branch to be merged into stable / testing branch
  • Is conditional branching a requirement of Turing-completeness?
  • So, can I create an ‘overlay’ onto a branch? Can I prevent certain files/directories from merging into my master branch?

  • Squashing or editing some commits before doing git-svn dcommit?
  • How can I limit the log to all the descendants of a given commit?
  • What user will Ansible run my commands as?
  • How to delete the content of github repository?
  • Is it possible to undo a git push --force on GitHub?
  • Git Missing Commit error
  • 2 Solutions collect form web for “Separate files in Git”

    You could define those same static files on your master branch but:

    • empty
    • witw a gitattributes files specifying you always want to keep your local version (i.e. empty) when merging those files

    Since that .gitattribute would not be define on other branches, the merge of those files would proceed normally.


    The idea is to define a .gitattributes file in the directory of those static files on the master branch with the following content:

    myStaticFile1 merge=keepMine
    myStaticFile2 merge=keepMine
    myStaticFile3 merge=keepMine
    

    Those three files will always keep their local content (which is empty on master) when merging to master.

    You will have to define a merge driver (here called “keepmine”). See the linked question for that script.

    Add the files to .gitignore in master. When you checkout devel, .gitignore will change and won’t ignore them anymore. (Note that if you run git clean -x, the files will be overwritten.)

    Git Baby is a git and github fan, let's start git clone.