Mikey’s Linux Field NotesAll topics

GUIDE 10 / DEVELOPMENT

Git & collaboration

Track changes, inspect history, and synchronize working copies through GitLab.

4 quick lessons · Examples to adapt to your server
In this guide
Review before committingSave a focused changeInspect history and remotesRemove tracking deliberately

Commands use class paths and example filenames. Replace placeholders and inspect the target before making changes.

01

Review before committing

The working tree holds your files; the index stages the next commit. git diff shows unstaged changes. Untracked file contents do not appear in a normal git diff.

COMMANDS & EXAMPLES
git status
git diff --stat
git diff
git diff --cached
Field note

A clean working tree means there are no pending local changes. It does not prove another computer has pushed its latest work.

02

Save a focused change

Stage named files, review the staged diff, commit, and push. A commit records a local snapshot; pushing sends commits to the remote.

COMMANDS & EXAMPLES
git add scripts/shell/health-check.sh
git diff --cached
git commit -m "Add service and website health checks"
git push
Field note

Keep private keys, credentials, logs, and personal note databases out of Git. Add appropriate patterns to .gitignore before staging new files.

03

Inspect history and remotes

--oneline gives a compact commit list. --stat adds per-file change statistics; plain log also shows author, date, and message. Remote inspection explains where fetches and pushes go.

COMMANDS & EXAMPLES
git log --oneline -3
git log --stat -1
git remote -v
git remote show origin
git pull --ff-only
Field note

Review local changes before pulling. A repository copy and ~/scripts/shell are separate directories; pulling updates only the repository. Copy the intended scripts into your working location afterward.

04

Remove tracking deliberately

git rm removes a tracked file from the working tree and stages its deletion. --cached stages removal from tracking while leaving the local file in place.

COMMANDS & EXAMPLES
git rm --cached notes-local.txt
git status
git ls-files --stage scripts/shell/health-check.sh
Field note

The removal example changes the index; use it only for a file you intend to stop tracking. Add that path to .gitignore if appropriate. Git mode 100755 preserves the executable bit, not every Unix permission, owner, or ACL.