Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
GimmeJob
Sign in
Git & collaboration · Chapter 14 / 14

Git & collaboration

A local collaboration lab and task reference

What the lab demonstrates

The runnable lab creates a local bare remote and two contributors in a new temporary directory. It executes real Git commands and checks resulting files, refs and exit codes. No hosting account, network access or token is needed for the lab itself.

It is a guided verification of Git mechanics, not a local implementation of GitHub permissions, PR reviews or CI. Those collaboration decisions are covered in chapters 10–11 and must be practiced using your team’s actual hosting rules.

Run from a repository checkout

You need Git 2.28+ and Python 3.9+. From the GimmeJob repository root:

python3 examples/git-collaboration/verify_workflow.py

On Windows, use a Python installation with Git available on PATH; the equivalent launcher can be py. The script uses Python’s standard library and invokes Git directly, so it does not require Bash, Docker, npm or a Python package installation. Downloading the project initially is separate from running this offline lab.

Follow the state transitions

The lab checks staging separately from later edits, an untracked-file stash, fetch without working-file mutation, a real rebase conflict, explicit resolution and an integration merge. It then verifies revert, a recovered detached commit, a second worktree, rejection of a stale explicit force-with-lease expectation, a bisect result and an annotated release tag.

Expected conflicts and rejected pushes must be recognized as expected results. Treating every nonzero command as an instruction to retry with force is precisely the error this lab is meant to expose.

Understand the evidence

Each stage prints a short PASS message only after its checks succeed. A failure raises an error with the local command and output. The script uses fictional identities, disables inherited Git configuration for the child commands and cleans up its temporary directory on exit. It does not change your current repository’s refs or global Git configuration.

Read the source alongside the transcript. Trace the local branch, remote branch and working-file contents before and after each operation. Passing the script is evidence for those scenarios in the installed Git environment, not certification of all possible Git workflows.

Inspect and record changes

TaskCommandState or limitation
Inspect current stategit status --short --branchIncludes untracked paths
Inspect unstaged changesgit diffWorking tree versus index
Inspect next commitgit diff --cachedIndex versus HEAD
Stage one pathgit add -- pathCaptures its current content
Unstage one pathgit restore --staged -- pathKeeps working edits
Record the indexgit commitCreates a local commit

Review the final staged diff and run appropriate checks before committing. A file’s current editor contents and its staged contents may differ.

Integrate and recover

TaskCommandDecision needed
Refresh remote knowledgegit fetch originNo automatic local integration
Update without divergencegit pull --ff-onlyRefuses a divergent history
Name a new taskgit switch -c feature/nameChoose the correct starting commit
Merge a fetched basegit merge origin/mainMay create a merge commit or conflict
Rebase a private featuregit rebase origin/mainReplaces replayed commit identities
Reverse a shared ordinary changegit revert COMMIT_IDReview inverse behavior and conflicts
Find recent local ref movesgit reflogRetention and local-only limitations

Commands with symbolic IDs require real inspected values. No command table can decide whether rewriting shared history is acceptable; that is a collaboration and authorization question.

Connect to the wider learning path

Related paths: programming, automation, Docker and Cloud & DevOps.

Checkpoint and answer

Question: Your force-with-lease push was rejected after a teammate updated the branch. What is the correct next step?

Answer: Fetch and inspect their actual update, coordinate ownership and preserve or integrate it. Do not refresh the expectation and repeat the push automatically; that would discard the protection’s purpose and can overwrite the teammate’s work.

Source registry

Review required
Git documentation: gittutorial

Command semantics and limitations for tutorial.

Git project · official documentation
Source ↗
Git documentation: git-push

Command semantics and limitations for push.

Git project · official documentation
Source ↗
Git documentation: git-bisect

Command semantics and limitations for bisect.

Git project · official documentation
Source ↗
Pull requests

Pull request context, draft state and collaboration models.

GitHub · official documentation
Source ↗