Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
44 views3 pages

How To Make A Patch File

The document explains how to create a patch file in Git that contains code changes. It describes that a patch file allows developers to share code modifications between repositories. It provides instructions for creating a single-commit or multi-commit patch file using the Git format-patch command and uploading the resulting .patch file.

Uploaded by

Gursimran Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views3 pages

How To Make A Patch File

The document explains how to create a patch file in Git that contains code changes. It describes that a patch file allows developers to share code modifications between repositories. It provides instructions for creating a single-commit or multi-commit patch file using the Git format-patch command and uploading the resulting .patch file.

Uploaded by

Gursimran Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Prerequisites

• You should have made the necessary changes cited in the task’s step-by-step guide

What is a patch file

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

• 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 if you don’t have push access to a repository
How to make a patch file
Scenario 1: You only made one commit for all the required changes

• Fire up a terminal, enter the repository via the terminal you opened (via the cd <repo_name_here> aka change
directory command) and run the command below

git format-patch -1 HEAD

• After executing the command, a .patch file will be produced in the directory where you executed the command. You
will upload this as your submission to the task
Scenario 2: You made multiple commits for all the required changes

• Fire up a terminal, enter the repository via the terminal you opened (via the cd <repo_name_here> aka change
directory command) and run the command below

git format-patch -n –stdout > multi_commit.patch

note: the n in -n must be replaced with a number which represents the number of commits you made for the
task. So the real command if you made 4 commits on top of the old commits should be

git format-patch -4 --stdout > multi_commit.patch

• After executing the command, a .patch file will be produced in the directory where you executed the command. You
will upload this as your submission to the task

You might also like