Create Patch Files

Create simple Email-format files which contain commit content with git.
For example,

$ git format-patch -M origin/master -5

The patch file has UNIX mailbox format context which is convenient for e-mail submission or for use with git am, we can use command git help format-patch to get more information about it.
The patch file looks something like this.

From 4e944b5c81169a7b6d8fc339019cd461344ed057 Mon Sep 17 00:00:00 2001
From: theArcticOcean <[email protected]>
Date: Tue, 2 Jul 2019 20:46:28 +0800
Subject: [PATCH 5/5] add resize event

 Introduce/mainwidget.cpp | 45 +-
 Introduce/mainwidget.h | 6 +-
 QThread/Makefile | 1109 ++++++++++++++++++----------------
 QThread/ | 51 +-
 semaphore/ | 60 +-
 5 files changed, 680 insertions(+), 591 deletions(-)

diff --git a/Introduce/mainwidget.cpp b/Introduce/mainwidget.cpp
index d29a199..5f742ab 100644
--- a/Introduce/mainwidget.cpp
+++ b/Introduce/mainwidget.cpp
@@ -10,13 +10,15 @@
 #include <QVBoxLayout>
 #include <QFileDialog>
 #include <QMainWindow>
+#include <QResizeEvent>

Git Apply And Git Am

We can add the content of patch file with git apply or git am.
git apply changes local files according to the patch, but no commit message in log history.

$ git apply 0003-use-splitter-as-stackWidget-page.patch
$ git status
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified: Introduce/mainwidget.cpp

We need to stage modified files and commit them manually.
git-am – Apply a series of patches from a mailbox, it can apply patch file’s diff result to the local work area and create commit message automatically.

$ git am 0003-use-splitter-as-stackWidget-page.patch
Applying: use splitter as stackWidget page

$ git log
commit 8804c21d5391812bbe8a2b716272f84058a8f2ae (HEAD -> dev)
Author: WeiYang <[email protected]>
Date: Tue Jul 2 17:44:28 2019 +0800

    use splitter as stackWidget page

commit a75dea9a36ca6cc03cbbd57ff03456558742b487
Author: WeiYang <[email protected]>
Date: Tue Jul 2 17:22:37 2019 +0800

    adjust height

Check if there is any whitespace: git diff --check.
Git marks the positions of whitespace red color if there are a few errors.

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments

XOR Strings
: Input your strings, the tool can encrypt and decrypt them.

Would love your thoughts, please comment.x