Reputation: 1745
Currently being in the process to git rebase
a branch into an other (which needs some adaptations and much of time), we need to do a hotfix on production (an other branch).
Is there a way to :
Upvotes: 0
Views: 150
Reputation: 489588
The short answer is no. Some items, such as the index, the HEAD
, and the in-progress rebase information, are stored in or associated with the work-tree.
You can, as you suggested in your own answer, make a new clone; or, with Git versions 2.6 or above, use git worktree add
. (The git worktree
feature appears in 2.5 but there was a brief rush of fixes followed by a longer trickle of smaller fixes, so this works best in the latest Git versions.)
What git worktree add
does is create additional work-trees using the existing repository. This is similar to making a new clone, except that the underlying .git
repository is shared directly. Each added work-tree has its own separate index, so instead of the index for the work-tree, you now have an index per work-tree. Instead of the HEAD
, you have one HEAD
per work-tree, and so on.
There is one hard restriction on git worktree add
: each work-tree must be in a separate branch. So if your main work-tree, the one you are in the middle of rebasing, is on branch develop
, your added work-tree cannot also be on branch develop
. If you want or need that, go ahead and use a separate clone. (You never actually need it but the details on this get tricky.)
Upvotes: 0
Reputation: 1745
I left the project as is and did a git clone
of it to an other folder. I'll code and commit the hotfix into the production branch of that new folder and will push them back to the original project folder when ready.
Upvotes: 1