Replies: 6 comments 1 reply
-
It does make me wonder if this is somehow related to #215? |
Beta Was this translation helpful? Give feedback.
-
I haven't taken a look, but you might need to run |
Beta Was this translation helpful? Give feedback.
-
Good thought! Running $ cd branchless-demo-2
$ git branchless init
Created config file at /Users/miquella/src/branchless-demo/.git/branchless/config
Auto-detected your main branch as: master
If this is incorrect, run: git branchless init --main-branch <branch>
Installing hook: post-commit
Installing hook: post-merge
Installing hook: post-rewrite
Installing hook: post-checkout
Installing hook: pre-auto-gc
Installing hook: reference-transaction
Successfully installed git-branchless.
To uninstall, run: git branchless init --uninstall
$ git sl
◇ e7d9765 6d (master) README
┃
◯ 12e5739 6d Something
┃
◯ 0adb2e7 6d Update README
┃
● bf05214 6d Something else
$ git move -x 0adb2e7 -d e7d9765
Attempting rebase in-memory...
[1/2] Committed as: c04d12b Something else
[2/2] Committed as: 0ef1c57 Update README
branchless: creating working copy snapshot
branchless: running command: git checkout c04d12b33f99e9c876826d5d6844946803357a78
Previous HEAD position was bf05214 Something else
branchless: processing 1 update: ref HEAD
HEAD is now at c04d12b Something else
branchless: processing checkout
◇ e7d9765 6d (master) README
┃
◯ 12e5739 6d Something
┃
● c04d12b 1s Something else
In-memory rebase succeeded. The resulting commit ( $ git unhide 0ef1c57
Unhid commit: 0ef1c57 Update README
To hide this 1 commit, run: git undo
$ git sl
◇ e7d9765 6d (master) README
┣━┓
┃ ◯ 12e5739 6d Something
┃ ┃
┃ ● c04d12b 2m Something else
┃
◯ 0ef1c57 2m Update README Correlating this with the repository layout docs seems to confirm that worktrees do share hooks with the original repo (although I'm not sure if |
Beta Was this translation helpful? Give feedback.
-
A colleague of mine reported problems with relative worktrees. Can you try with an absolute path to the worktree and see if that resolves the issue? |
Beta Was this translation helpful? Give feedback.
-
Oh, great idea! Unfortunately, it looks like it's already an absolute path: $ cat .git
gitdir: /Users/miquella/src/branchless-demo/.git/worktrees/branchless-demo-2 |
Beta Was this translation helpful? Give feedback.
-
In my case,
I get
Although later I see that your reference-transaction and post-commit hooks seem to have triggered properly. After following along with the rest of the steps, it didn't reproduce, and the
Perhaps your hooks are installed incorrectly (if you use |
Beta Was this translation helpful? Give feedback.
-
Hello wonderful friends!
I've been quite confused by
git move
for a long time and believe I realized why today: worktrees!Background
I tend to have a lot of incomplete streams of work that I switch between often, so I have several worktrees open at any given time (although
git-branchless
has helped to reduce this quite a bit, I haven't completely kicked the habit just yet 😜). To make matters worse, I tend to not use branches either.While working in one of these branchless worktrees, I often come across an unrelated issue. So I fix the issue and commit it separate from the rest of my work. Once I reach a stopping point, I cherry-pick those changes onto the main branch and rebase them out of my commit history.
Confusion
Once I picked up
git-branchless
, I realized that I could simplify (or so I thought…) this workflow by usinggit move
!The thing that's always confused me is that it never seemed to work. I would
git move -x <COMMIT> -d <MAIN>
and … nothing would change. Or worse, sometimes the commit would just be gone! Thankfully, when it was missing, some combination ofgit undo
and/or scouring the output would allow me to recover the missing commit.Today while trying to figure out what was going on, I realized this only fails in worktrees 😮 If I switched to my standard clone, everything works fine!
So my question is: am I doing something wrong? Perhaps I'm just expecting the wrong thing?
Demo
To demonstrate the issue, I setup a new repo:
Switched to a worktree:
And did some "work":
Then attempt to move something:
But now the "Update README" commit is gone from the smartlog! I've learned that if I carefully read the output, I can unhide the commit and then the smartlog appears as I would expect:
Beta Was this translation helpful? Give feedback.
All reactions