Member-only story

How to Create and Apply Git Patch File.

Joy Joel
3 min readSep 4, 2020

--

You should know by now that git is a way for developers to manage code in a project especially if there’s other developers collaborating in that project too.

What is a Patch File

A git patch file is just a file that you can apply to a repository to get the changes/modifications/additions another developer did on his / her machine onto your local machine. This isn’t the only way to do that of course but this is a viable method for a head/lead developer to check your code first before merging it into the repository’s main/master branch.

Git patch files are very beneficial : they are used in order to store differences that need to be applied to a file or a group of files on your system.

Git patch is historically linked to the Unix “patch” command that was used in early Unix versions to store differences between files or binaries.

Create Git Patch Files

To create a Git patch file, you have to use the “git format-patch” command, specify the branch and the target directory where you want your patches to be stored.

$ git format-patch <branch> <options>

The “git format-patch” command will check for commits that are in the branch specified but not in the current checked-out branch.

Running a “git format-patch” command on your current checkout branch won’t output anything at all.

--

--

Joy Joel
Joy Joel

Written by Joy Joel

Abba’s Daughter| DevOps Engineer|Technical Writer

No responses yet

Write a response