Wilson Mar bio photo

Wilson Mar


Email me Calendar Skype call

LinkedIn Twitter Gitter Instagram Youtube

Github Stackoverflow Pinterest

Create patch messages to apply into other repos, like old-school pros

US (English)   Norsk (Norwegian)   Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Estonian   اَلْعَرَبِيَّةُ (Egypt Arabic)   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean


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.

Man page

  1. On a Terminal, to see Git’s documentation on the git patch command:
    man git-patch

    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.

  2. 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.

    NOTE: Thanks to Prem Sichanugrist for his blog about git patch of piping several messages into a single patch file.

Git Branching Model

Git patches are used by the Git core team branching model is described in this Oct 21, 2016 video by Nicola Paolucci when he was a Developer Advocate at Atlassian.


  • 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:

  1. Git and GitHub videos

  2. Why Git? (file-based backups vs Git clone)
  3. Git Markdown text

  4. Git basics (script)
  5. Git whoops (correct mistakes)
  6. Git messages (in commits)

  7. Git command shortcuts
  8. Git custom commands

  9. Git-client based workflows

  10. Git HEAD (Commitish references)

  11. Git interactive merge (imerge)
  12. Git patch
  13. Git rebase

  14. Git utilities
  15. Git-signing

  16. Git hooks
  17. GitHub data security
  18. TFS vs GitHub

  19. GitHub actions for automation JavaScript
  20. GitHub REST API
  21. GitHub GraphQL API
  22. GitHub PowerShell API Programming
  23. GitHub GraphQL PowerShell Module