git: can you associate files with a branch without committing them?

Viewed 35

I have some unstaged files that I want to use with features in one branch (it's testing data) and when I switch branch I would like these files to go away (stay with the branch) and come back when I switch back to it. I know I could git stash the files and then git pop them when I switch back - but then I need to keep this in mind myself - I'd like to have it automatically happen. I don't want to commit the files though as they should not end up in the commit i gonna push.

Can this be done? if so, how?

1 Answers

I would consider using .gitignore in combination with a post-checkout git hook.

This way you can be sure the changes will be ignored but can also trigger a file copy or delete when using git checkout

https://schacon.github.io/git/githooks.html

Related