3

I'd like to be able to make local (never tracked, never committed) files "stick" to certain git branches.

For example, I'd like to be able to do something like:

$ git checkout version1.0
$ make
$ ./myProject # 1.0 binary
$ git stick-to-current-branch myProject
$
$ git checkout version2.0
$ make
$ ./myProject # 2.0 binary
$ git stick-to-current-branch myProject
$ 
$ git checkout version1.0
$ ./myProject # 1.0 binary from above

I made up the "stick-to-current-branch" command, but is there something that does this for real? I never want to commit these files; they're branch-specific but shouldn't be tracked.

kris
  • 23,024
  • 10
  • 70
  • 79

2 Answers2

3

No, there is no option to "stick" a file that is not tracked by git in the checked out working directory of different branches. You can however "generate" the file during checkout ( like using a post-checkout hook - run your make in the post-checkout hook so that the myProject binary is generated for the branch / version)

manojlds
  • 290,304
  • 63
  • 469
  • 417
1

(note: not for binaries)
If the content a myProject file is easily identifiable, you could use a filter driver in order to generate the right content for that file based on the current branch.

enter image description here

On each checkout, you would use the smudge script to generate the private file (as in "not versioned") 'myProject', based on a template file 'myProject.tpl' with all the right values for all the different branches.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    I think running a `post-checkout` hook would be a better option, especially since this is a binary and I don't think this would work with binary files? – manojlds Sep 07 '11 at 21:22
  • @manojlds: which is why my answer starts with "note: not for binaries" ;) – VonC Sep 07 '11 at 21:28