Assume I am one of many developers working with git on a huge code project, which has an incredibly long compilation time.
Now, my personal day-to-day changes are usually limited, and the codebase is decently modular, which means that as far as my personal work is concerned, compiling from scratch is a price that only has to be paid once. Afterwards, I can recompile only the modules I modified.
On the other hand, I frequently have to fix bugs in (at least two) branches which reflect states of the codebase completely distinct from the branch I work on. Those two branches are indeed the result of work from the entire development team, and often have entire modules rewritten or added. Having compiled everything before pushing a bugfix is mandatory.
My first approach was to switch from my development branch every time a bugfix is needed, then clean, bugfix, recompile from scratch, push, switch back to the original branch, clean again, recompile - the delay for doing this is intolerable.
I then moved to keeping three separate checkouts of the codebase on my machine. This solves the "costly recompilation" problem (my changes in every branch are incremental again), but it makes the question "what am I developing on right now ?" more complex to answer (since it depends on the current directory), and it makes synchronization of these three copies complex (it multiplies all the routine push
/remote update
/pull
commands I have to do by three).
A simpler solution would be to have the ability to save the state of a directory (untracked, where I generate compiled files) every time my checkout "leaves"a branch, and to recall the state of that directory, if it exists, every time I "enter" (checkout) a branch.
- Are there git commands that would help me achieve this behavior ?
- If not, is there a tool that would allow me to do that ?
- If not, does git provide checkout hooks that could help me script this behavior ?