如何使用git 發patch

2021-06-19 10:04:09 字數 1522 閱讀 4369

多發patch,多產生一些好的

idea,才可以在open software community中越混越好。

首先配置git。這裡有兩種配置檔案,乙個是全域性的,在使用者的home目錄下,乙個是相應git倉庫的。如果你設定了全域性的,那麼可以用在各個git倉庫上。檢視一下我已經配置好的配置檔案:

hacker@hacker:~/qemu-kvm$ cat

~/.gitconfig 

[user]

name = wanpeng li

email = [email protected]

[sendemail]

chainreplyto = fals

esmtpserver=/usr/bin/msmtp

我們可以使用命令

來配置:

$git config --global user.name 'wanpeng li'

$git config --global user.name '[email protected]'

$git config --global sendemail.chainreplyto false

$git config --global sendemail.smtpserver /usr/bin/msmtp

另乙個需要配置的就是msmtp的配置檔案,如果沒有安裝msmtp使用apt-get install安裝。

hacker@hacker:~/qemu-kvm$ cat ~/.msmtprc 

account default

host ap.relay.ibm.com

#auth plain

user [email protected]

password ***xx

from [email protected]

當你修改原始碼檔案後,使用git commit -a可以給你的patch加一些注釋,注意第一行新增的是patch的名字,然後空一行,然後另啟一行新增對patch的注釋。注意這patch的名字和注釋之前必須空一行。然後新增"signed-off-by: "eg:

signed-off-by: wanpeng li

然後生成patch檔案,使用命令git form

at-patch,eg:

$git format-patch origin

如果覺得這個commit不想要了用git reset:

$git reset

head^

然後傳送出去:

要使用git-send-email之前先要apt-get install git-email

$git send-email  --to ***@*** --to ***@*** --cc ***@***   ***xx.patch

下面就是我發出的這個patch的截圖,雖然比較爛的patch,但是學會了怎麼發patch,走出了第一步。

如何使用git 生成patch

git clone git cd bluetooth next 2.6 2,修改 vi drivers bluetooth btusb.c 3,把 新增到git管理倉庫 git add drivers bluetooth btusb.c 4,提交修改 git commit m added ather...

git 中的 patch 使用

git協同開發時,patch在某些場景下,是個不錯的選擇.patch其實就是乙個git diff記錄,那為什麼要用它呢?git那麼多協同開發的工具,難道非要用它?方法其實很多,但我這裡更推薦下面方式 先將feature fix正常提交到某個分支 git log檢視提交前的old commitid 第...

如何利用git製作和提交patch

不過在git中,我們沒有必要直接使用diff和patch來做補丁,這樣做既危險又麻煩。git提供了兩種簡單的patch方案。一是用git diff生成的標準patch,二是git format patch生成的git專用patch 我們可以首先用git diff製作乙個patch。本文示例的工作目錄...