FIND YOUR NEXT FEW LINES

Results for “branch”

Small, practical examples. Search by task or narrow things down below.

64 snippets foundClear filters
TypeScriptGetting Started

Handle three possible outcomes

TypeScript: Check high, normal and low values with an ordered conditional chain.

TypeScript✓ Tested
C++Getting Started

Handle three possible outcomes

C++: Check high, normal and low values with an ordered conditional chain.

C++✓ Tested
CGetting Started

Handle three possible outcomes

C: Check high, normal and low values with an ordered conditional chain.

C✓ Tested
GitBranches & ancestry

Inspect a revision with detached HEAD

Git: Detached mode is useful for inspection; create a branch before keeping new work.

Git✓ Tested
GitBranches & ancestry

Test whether one revision is an ancestor of another

Git: merge-base --is-ancestor reports its answer through the exit status.

Git✓ Tested
GitMerging & replaying changes

Abort a conflicting cherry-pick

Git: Abort removes the incomplete replay and returns to the previous branch state.

Git✓ Tested
GitMerging & replaying changes

Abort a conflicting rebase

Git: Abort returns the branch to its state before the rebase attempt.

Git✓ Tested
Bash ScriptsArguments & decisions

Choose among several numeric ranges

Bash Scripts: An if-elif chain evaluates branches in order and executes the first match.

Bash Scripts✓ Tested
TypeScriptSafe data handling

Handle a result with a discriminated union

Separate success data from an error message.

discriminated union✓ Tested
Bash ScriptsFunctions & arguments

Handle an expected command failure

Branch on a command’s exit code without aborting the script.

exit status✓ Tested
TypeScriptTypes & functions

Narrow a union using typeof

Handle text and numeric values with separate branches.

union✓ Tested
GitRemotes & collaboration

Pull without creating a merge commit

Update a branch only when its upstream can be fast-forwarded.

pull✓ Tested