liveBook · Manning

Git

As explained in Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

Git is a distributed version-control system for tracking and managing changes to files and coordinating work on software projects.

Git is a decentralized source-control system for tracking PowerShell projects and coordinating changes. Each contributor can keep a local copy, periodically merge updates, and publish a protected or web-hosted copy when needed. Its command-line workflow is worth learning because most Git guidance uses it. section 19.2 section 19.0

Build a practical local workflow from a project folder:

  • Install the Windows client, restart any existing PowerShell session so the updated path is detected, and configure a username and email address. section 19.2.1 section 19.2.2
  • Create or enter the project’s root directory, then run git init. Git creates a hidden .git directory and a main branch; run commands from the repository root. section 19.3 section 19.3.1
  • Use git status to find untracked files, git add to stage them, and git commit -m to create a named checkpoint. section 19.3.1 section 19.3.3
  • Inspect history with git log, use branches for isolated development, compare branches with git diff, and merge finished work into main. section 19.3.3 section 19.3.5

Develop safely on a branch

Inside MyPSTool, create and check out a dev branch, add devdata.txt, stage and commit it, then return to main. The new file is absent from main until git merge dev integrates it. Afterward, delete the completed branch with git branch -d dev. This keeps experimental work separate from the current version and makes scrapping unfinished work less disruptive. section 19.3.5

Publish and synchronize a project

Create a GitHub repository for an existing local project, add it as the origin remote, and push main with git push -u origin main. Later commits can be pushed normally; git fetch retrieves remote updates, git pull applies them locally, and git clone creates a local working copy of another repository. section 19.5

PS C:\> git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
...

Use the command-line usage listing as a quick orientation before consulting detailed command help or the Git tutorial. section 19.2.2

How Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools covers it

How deep it goes
Explains installation, configuration, repositories, commits, rollback, branching, merging, and GitHub synchronization through command-line demonstrations.
Examples
Demonstrates MyPSTool, PowerShell script files, data.txt, devdata.txt, commit history, rollback, branch merging, and GitHub remotes.
What it assumes
Assumes basic PowerShell folder and file operations, while teaching Git installation, identity configuration, repository initialization, and core commands.
What you can do after
Operate Git from PowerShell to track files, create checkpoints, isolate changes, undo commits, merge branches, and synchronize GitHub repositories.
How it connects
Connects source control with PowerShell, commits, branching, merging, repositories, GitHub, and collaborative development.

Also explained in

Compare how 8 books explain git →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools. The section links point to the parts of the book it draws on.