-
-
Notifications
You must be signed in to change notification settings - Fork 90
Command: git hide, git unhide
Available since v0.1.0.
The git hide
command is used to hide commits from the smartlog when you no longer want to see them anymore. It's essentially the same as deleting a branch, except that branches aren't necessary in the branchless workflow.
The git unhide
command is used to undo the effects of git hide
. Note that you can also use git undo
in some cases.
To hide a single commit, run git hide <hash>
:
$ git sl
⋮
◆ 86bdeac0 48d (master) Revert "Update foo"
┃
◯ 8d4738cd 2d new message
┣━┓
┃ ◯ 814b2b05 2d temp: another commit
┃
◯ 67687b48 2d temp: update foo
$ git hide 67687b48
Hid commit: 67687b48 temp: update foo
To unhide this commit, run: git unhide 67687b48
$ git sl
⋮
◆ 86bdeac0 48d (master) Revert "Update foo"
┃
◯ 8d4738cd 2d new message
┃
◯ 814b2b05 2d temp: another commit
To hide an entire subtree, not just a single commit, pass the -r
/--recursive
flag to git hide
:
$ git sl
⋮
◆ 86bdeac0 48d (master) Revert "Update foo"
┃
◯ 8d4738cd 2d new message
┣━┓
┃ ◯ 814b2b05 2d temp: another commit
┃
◯ 67687b48 2d temp: update foo
$ git hide -r 8d4738cd
Hid commit: 8d4738cd new message
To unhide this commit, run: git unhide 8d4738cd
Hid commit: 814b2b05 temp: another commit
To unhide this commit, run: git unhide 814b2b05
Hid commit: 67687b48 temp: update foo
To unhide this commit, run: git unhide 67687b48
$ git sl
⋮
◆ 86bdeac0 48d (master) Revert "Update foo"
ℹ️ Tip: If you want to undo a git hide
immediately after doing it, it's easier to run git undo
.
To unhide a given commit later, run git unhide
with that commit hash:
$ git unhide 67687b48
Unhid commit: 67687b48 temp: update foo
To hide this commit, run: git hide 67687b48
$ git sl
⋮
◆ 86bdeac0 48d (master) Revert "Update foo"
┃
◯ 8d4738cd 2d new message
The git unhide
command also takes the -r
/--recursive
flag to unhide an entire subtree.
ℹ️ Tip: If you want to unhide a certain commit, but don't remember its commit hash, you can use git undo
to find the old commit hash and copy it, and then cancel the undo operation.
If you hide a single commit, but not its its descendants, that commit and its descendants will still be visible in the smartlog:
$ git sl
⋮
◆ 86bdeac0 48d (master) Revert "Update foo"
┃
◯ 8d4738cd 2d new message
┣━┓
┃ ◯ 814b2b05 2d temp: another commit
┃
◯ 67687b48 2d temp: update foo
$ git hide 8d4738cd
Hid commit: 8d4738cd new message
To unhide this commit, run: git unhide 8d4738cd
$ git sl
⋮
◆ 86bdeac0 48d (master) Revert "Update foo"
┃
✕ 8d4738cd 2d (manually hidden) new message
┣━┓
┃ ◯ 814b2b05 2d temp: another commit
┃
◯ 67687b48 2d temp: update foo
A child commit of a hidden commit is said to be "abandoned". git-branchless
still shows the hidden commit because it wants you to do something about the abandoned children.
There are a few things you can do:
- If the commit was hidden by mistake, you can unhide it with
git unhide
. - If you don't want the commit or any of its descendants anymore, you can hide them all with
git hide -r
. - If you want to keep only the descendant commits, but not the parent commit, you can use
git move
to move them off from the parent commit.- For example,
git move -s 67687b48 -d master
will move thetemp: update foo
commit on top of themaster
branch. (Themaster
branch won't be changed.)
- For example,
- If the abandoned child appeared because of a rewrite operation, and you want to move its descendant commits to the newest version of that commit, use
git restack
.
- Search the Wiki 🔎
- User guide
- Welcome
- Installation
- Tutorial
- Command overview
- General:
- Navigation:
- Committing:
- Rebasing:
- Verification:
- Collaboration:
- Workflows
- Advanced topics
- Reference
- Developer guide
- Onboarding offer
- Development
- Reference