gitless icon indicating copy to clipboard operation
gitless copied to clipboard

Fuse refuse to move a branch without commits

Open chmike opened this issue 8 years ago • 1 comments

I was in a situation where I created a branch and started modifying files. I then had to do an independent change, for which I created a new branch attached to master. I completed the change by merging the code to master.

I then wanted to resume work on the previous branch. But first I wanted to move the branch to the head of master which has moved forward. Since I didn't commit the changes, the gl fuse -ip HEAD wip refused to fuse because there are no commits in the branch.

It should allow to move a branch, which in this case is simply changing it's attachment point.

As a solution, I could create a new branch at the HEAD of master and move my modified files from the old branch to the new branch. But that new branch would need to have a different name from the old branch. Since I can't rename the old branch so that I can keep it's name I'm stuck.

Of course I can use git commands to fix this, but that's not the point of the exercise.

chmike avatar Dec 01 '16 10:12 chmike

If you create a new local branch that mirrors the master then switch from the previous branch to the new branch while specifying gl switch -mo, you are not necessarily stuck.

If you wish to continue working with the local branch of the same name as before, you can do one of the following after moving the uncommitted files over to the previous branch:

PROCEDURE 1: RECREATE THE LOCAL BRANCH WITH THE DESIRED NAME

  1. delete the old branch with the name you want
  2. re-create the branch with the same name that mirrors the master branch (by specifying the -dp option with the master branch name as part of the gl branch -c command)
  3. switch back again from the poorly named branch into the branch with the desired name that is now a mirror of the master branch via gl switch -mo to copy back the uncommitted files
  4. delete the poorly named branch

PROCEDURE 2: FUSE THE LOCAL BRANCH WITH THE MASTER

  1. do a normal switch (do NOT specify -mo) back to the old branch with the desired name. The local branch you switch out of will retain the uncommitted files and switching back to the old branch brings you back to a clean head.
  2. fuse with the master branch
  3. do a normal switch back to the poorly named branch with the uncommitted files
  4. switch back from the poorly named branch into the branch with the desired name that is now a mirror of the master branch via gl switch -mo to copy back the uncommitted files
  5. delete the poorly named branch

Of course, having a rename feature like you recommended earlier would make life so much easier. But if you wanted the "Gitless" way to synchronize a branch having uncommitted files with another branch that is a few commits ahead and preserve both the uncommitted files and the local branch name, that is the way to do it.

Sincerely, Al

cougarhawk avatar Aug 19 '17 00:08 cougarhawk