Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Git Best Practices Guide

You're reading from   Git Best Practices Guide Master the best practices of Git with the help of real-time scenarios to maximize team efficiency and workflow

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher
ISBN-13 9781783553730
Length 102 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
PIDOUX Eric PIDOUX Eric
Author Profile Icon PIDOUX Eric
PIDOUX Eric
Arrow right icon
View More author details
Toc

Creating a patch

Let's explain what a patch is with an example. An external programmer was called by Jim to make small fixes in a part of the project, but Jim didn't want to give him access to the repository, thus preventing him from pushing data. So, he decides to make a patch and sends it by e-mail to Jim:

External@local:~/webproject$ git format-patch origin patch-webproject.patch

This command will create .patch files per commit and the external programmer will send the e-mail with it. So, he decides to make a patch and send it by e-mail to Jim.

Jim can import the patch by executing this:

Jim@local:~/webproject$ git apply /tmp/patch-webproject.patch

This command will apply the patch, but it doesn't create commits.

So, to generate a series of commits, use the git am command:

Jim@local:~/webproject$ git am /tmp/patch-webproject.patch
You have been reading a chapter from
Git Best Practices Guide
Published in: Nov 2014
Publisher:
ISBN-13: 9781783553730
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime