The scenario is that I'm in the middle of a task, in a feature branch, and then I've been asked to do a quick hot fix, or do some tests on another branch.
And so, one approach is to close up my current work, either stashing (and hope I remember that I've stashed it), or commit it to my local repo, with then the option of pushing that with a "WIP" prefix (Work In Progress).
All of which are really annoying and can take time.
What I would like to happen is that I run something like:
git fetch
git something to clone the required branch, or create a new branch for the required hotfix into a separate directory with that directory not needing to have the full .git folder
cd to other folder
do the work
git add .
git commit -m 'Some sarky comment that no one reads'
git push
cd back to my main checkout
git something to make it forget all about the other directory and maybe even delete it!
and just carry without needing to unstash or any other waste of time stuff
Of course, this could all be wrapped up into a shell function or script, and so be simplified.
I had thought sub-trees where the thing, but I couldn't get the subtree created.
As an example, working with app
and wanting to look at master:
$ git subtree add -d --prefix=../app-master/ origin master
command: {add}
quiet: {}
dir: {../app-master}
opts: {origin master}
git fetch origin master
From bitbucket.org:digitickets/app
* branch master -> FETCH_HEAD
Adding ../app-master as 'b03a1ea06e26cfae0d49483c9027ecd6aab210c8'...
error: invalid path '../app-master/.babelrc'
At this point in time, the ../app-master
directory doesn't exist.
If I create that directory:
$ git subtree add -d --prefix=../app-master/ origin master
prefix '../app-master' already exists.
The error that git-subtree is making is in response to:
git read-tree --prefix=../app-master b03a1ea06e26cfae0d49483c9027ecd6aab210c8
which sort of suggests that the content of ../app-master
should already be populated.
And so, I think I've misunderstood what Git's SubTrees are all about or that I'm attempting to misuse them and so not going to work.
Any suggestions?