Results for “Inspecting the working tree”
Small, practical examples. Search by task or narrow things down below.
Set a working directory
Choose the default directory for later instructions and the running process.
Dockerfile✓ Tested
List all files stored in a commit
Git: ls-tree inspects the committed tree without relying on working files.
Git✓ Tested
Change directory only for one operation
Bash Scripts: A subshell makes a temporary directory change without affecting later commands.
Bash Scripts✓ Tested
Copy a directory while preserving attributes
Linux Commands: Use cp -a for a recursive local copy that preserves links and ordinary file attributes.
Linux Commands✓ Tested
Ignore generated files
Exclude build output from untracked-file listings.
gitignore✓ Tested
List changed files without the full diff
Inspect affected paths before staging.
diff✓ Tested
Stage one file
Add one changed file to the next commit.
add✓ Tested
Stash edits to one chosen file
Git: A pathspec limits the stash to selected paths while other changes remain in the working tree.
Git✓ Tested
Temporarily store tracked-file edits
Restore a clean working tree and then reapply your saved changes.
stash✓ Tested
Unstage a file without losing edits
Return a staged change to the working tree.
restore✓ Tested
Append several items to an array
Bash Scripts: Array-plus-equals adds elements without losing spaces inside a quoted item.
Bash Scripts✓ Tested
Assign a default to an empty or unset variable
Bash Scripts: The colon-equals expansion both supplies and assigns a fallback value.
Bash Scripts✓ Tested