Wilson Mar bio photo

Wilson Mar

Hello. Hire me!

Email me Calendar Skype call 310 320-7878

LinkedIn Twitter Gitter Instagram Youtube

Github Stackoverflow Pinterest

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

Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Cyrillic Russian   中文 (简体) 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.

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 hooks
  16. GitHub data security
  17. TFS vs GitHub

  18. GitHub REST API
  19. GitHub GraphQL API
  20. GitHub PowerShell API Programming
  21. GitHub GraphQL PowerShell Module