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 and applying patches


A patch is a piece of code that can apply a set of changes (that is, a commit) to any branch and any order of a project. The main goal of this feature is to share the changes with other developers, and it gives control to the project maintainer (whether they choose to incorporate the contribution or not). Creating a patch in Git is very easy, as we will see right now.

Creating a patch

Creating a Git format patch will include metadata on the specified commit (author, message, and so on). Everything will be formatted as an easy-to-send e-mail. So, the recipient of this patch will be able to recreate the commit with git am.

In fact, the git format-patch command is useful to transfer a commit. Otherwise, the git diff command finds differences inside the code.

In cases where we want to create a patch for one commit, we have to add the sha1 code of the commit.

The git log command, as we saw in Chapter 2, Working in a Team Using Git, shows the commits:

Erik@server:~$ git...
lock icon The rest of the chapter is locked
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