Results for “branches”
Small, practical examples. Search by task or narrow things down below.
Read the current branch name
Git: show-current returns an empty string when HEAD is detached.
Git✓ Tested
Rename the current branch
Git: branch -m changes the local branch name without creating a new commit.
Git✓ Tested
Return to the previously checked-out branch
Git: The dash shorthand selects the previous branch in the checkout history.
Git✓ Tested
Test whether one revision is an ancestor of another
Git: merge-base --is-ancestor reports its answer through the exit status.
Git✓ Tested
Choose among several numeric ranges
Bash Scripts: An if-elif chain evaluates branches in order and executes the first match.
Bash Scripts✓ Tested
Create and switch to a branch
Start an isolated feature branch from the current commit.
switch✓ Tested
Merge a branch only by fast-forward
Refuse to create an unexpected merge commit.
merge✓ Tested
Narrow a union using typeof
Handle text and numeric values with separate branches.
union✓ Tested
Remove stale remote-tracking references
Git: Fetch with prune removes tracking references for branches no longer present on the remote.
Git✓ Tested
Temporarily store tracked-file edits
Restore a clean working tree and then reapply your saved changes.
stash✓ Tested
Undo a commit with a new commit
Reverse a change while preserving shared history.
revert✓ Tested