Create patch messages to apply into other repos, like old-school pros
This is a hands-on tutorial on how to use Git patch from the command line and in a Bash script.
NOTE: Content here are my personal opinions, and not intended to represent any employer (past or present). “PROTIP:” here highlight information I haven’t seen elsewhere on the internet because it is hard-won, little-know but significant facts based on my personal research and experience.
- On a Terminal, to see Git’s documentation on the git patch command:
A Git patch file is a mail document which updates a Git repository using the git am command instead of a git commit command.
This approach is used by Linux Core developers.
PROTIP: This can be a scary operation, so I’ve written a Bash script to make it easier, faster, and safer.
In an internet browser such as Google Chrome or Mozilla Firefox, visit my Bash script “git-patch.sh” at:
The Bash scripting in the file is explained in:
https://wilsonmar.github.io/bash-coding and in this document.
The script “git-patch.sh” clones a repo, creates a patch, opens another repo, and applies those changes.
Git Branching Model
- np/topic branch are discussed using patches emailed
- pu = proposed updates
- next branch are changes about to be merged into master
- next and maintenance branches are reset after releases
This is one of a series on Git and GitHub:
- Why Git? (file-based backups vs Git clone)
- Git basics (script)
- Git whoops (correct mistakes)
- Git command shortcuts
- Git interactive merge (imerge)
- Git patch
- Git utilities
- Git hooks
- GitHub data security
- GitHub REST API
- GitHub GraphQL API
- GitHub PowerShell API Programming
- GitHub GraphQL PowerShell Module