1. 程式人生 > >git 怎麼用命令傳送patch補丁、send-email下載和配置

git 怎麼用命令傳送patch補丁、send-email下載和配置

本文是在Ubunt 12.04環境下測試的。

1、安裝必要的軟體

  1. # apt-get install git git-core git-email


2、配置send-email的環境,主要是設定本地email的客戶端,用msmtp

vim ~/.msmtprc
 

  1. # default
  2. account gmail
  3. protocol smtp
  4. host smtp.gmail.com
  5. from [email protected].com
  6. user [email protected].com
  7. password ******
  8. port 587 
  9. auth on
  10. tls on

  11. tls_trust_file /etc/ssl/certs/ca-certificates.crt
  12. syslog LOG_MAIL
  13. set a default account
  14. account default : gmail


3、設定git send-email的配置
vim ~/.gitconfig

  1. [user]
  2.     name = your name
  3.     email = [email protected].com
  4. [sendemail]
  5.         smtpencryption = tls 
  6.         smtpuser = [email protected]
    .com
  7.         smtpserverport = 587 
  8.         smtpserver = smtp.gmail.com 
  9. to = [email protected].com
  10. # cc = [email protected].com
  11. # from = [email protected].com
        

其中,上面配置檔案的最後三行在git send-email傳送補丁檔案時也可以通過命令列指定。建議大家最好通過命令列指定,因為核心補丁檔案需要傳送給相關模組的maintainer。


4、下面就以例項來說明如果製作一個符合規範的核心補丁。
Linux核心補丁的製作規範和傳送格式參見核心文件Documentation/SubmittingPatches。
a、修改核心

  1. diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c
  2. index a5c36c0..f8e0d73 100644
  3. --- a/net/sunrpc/auth_null.c
  4. +++ b/net/sunrpc/auth_null.c
  5. @@ -27,+27,7 @@ nul_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
  6.  static void
  7.  nul_destroy(struct rpc_auth *auth)
  8.  {
  9. + pr_info("hellor world!\n");
  10.  }


b、提交修改

  1. git commit ---m"test" -e


其中,-a表示all,-s表示在補丁檔案頭部增加Signed-off-by行,-m表示指定commit資訊,-e表示使用git預設的編輯器來對commit資訊進一步編輯,我這裡預設的編輯器是nano。關於更詳細的引數選項可以用命令git commit -h來察看。

執行上面那個命令以後,會進入到nano編輯器中,然後進行編輯。其中第一行顯示的是補丁檔案頭部的Subject資訊,第二行文字顯示的是補丁檔案的註釋資訊。編輯完以後,ctrl-o儲存,ctrl-x退出。  
 
 
c、生成補丁檔案

  1. git format-patch -1
其中,-1表示生成一個補丁檔案,即最後git commit時的修改。用vim開啟補丁檔案,如下所示:
 
 
之所以要有Subject,Signed-off-by檔案,那是因為核心文件Documentation/SubmittingPatches檔案中有說明:

15) The canonical patch format

The canonical patch subject line is: 

    Subject: [PATCH 001/123] subsystem: summary phrase

The canonical patch message body contains the following:

- A "from" line specifying the patch author.

- An empty line.

- The body of the explanation, which will be copied to the 
    permanent changelog to describe this patch.

- The "Signed-off-by:" lines, described above, which will
    also go in the changelog.

- A marker line containing simply "---".

- Any additional comments not suitable for the changelog.

- The actual patch (diff output).

d、檢測補丁
製作完補丁檔案以後,不要急著把補丁檔案mail出去,需要先檢測一下這個補丁的正確性。核心中提供了一個補丁檢測指令碼。在核心原始碼根目錄下,補丁檢測如下:
  1. ./scripts/checkpatch.pl 0001-nfs-add-a-pr_info.patch 
  2. total: 0 errors, 0 warnings, 7 lines checked
  3. 0001-nfs-add-a-pr_info.patch has no obvious style problems and is ready for submission.

e、確定補丁傳送給誰
補丁檢測通過以後,就可以mail出去了。但是該mail給誰呢?嗯,核心裡面也同樣提供了一個指令碼,用於檢測某個目錄的maintainer是誰。以我修改的net/sunrpc目錄裡面的檔案為例,執行下面的命令:

  1. [email protected]-PC:~/code/linux-3.5.4# ./scripts/get_maintainer.pl net/sunrpc/ -f
  2. Trond Myklebust <Trond.[email protected].com> (maintainer:NFS, SUNRPC, AND...)
  3. "J. Bruce Fields" <[email protected].org> (supporter:KERNEL NFSD, SUNR...)
  4. "David S. Miller" <[email protected].net> (maintainer:NETWORKING [GENERAL])
  5. linux-[email protected].kernel.org (open list:NFS, SUNRPC, AND...)
  6. [email protected].kernel.org (open list:NETWORKING [GENERAL])
  7. linux-[email protected].kernel.org (open list)
從上面輸出可以看到,email destination有三個人。而後面的3個則用於email carbon copy (cc),即抄送。

5、傳送補丁
命令如下所示:
  1. [email protected]-PC:~# git send-email --smtp-server /usr/bin/msmtp --to [email protected].com 
  2. --cc [email protected].com 0001-nfs-add-a-pr_info.patch

其中,git send-email的選項選項說明如下:
--to 郵件的To地址 sendmail.to
--cc 郵件的Cc地址 sendmail.cc
--smtp-server SMTP伺服器名稱 sendmail.smtp-server

關於git send-email的詳細選項說明,可以通過執行命令git send-email -h察看。
注意,這裡是通過命令列引數設定,前面說過,在~/.msmtprc檔案也可以設定全域性引數。
如果大家要測試的話,可以將--to和--cc設定成自己的郵箱地址。

相關推薦

git 怎麼命令傳送patch補丁send-email下載配置

本文是在Ubunt 12.04環境下測試的。 1、安裝必要的軟體 # apt-get install git git-core git-email 2、配置send-email的環境,主要是設定本地email的客戶端,用msmtp vim ~/.msmtprc   # default a

git 命令下載程式碼到本地

有的程式碼編輯工具裡沒有匯入功能,可以用git命令匯入 第一步:建立一個本地的版本庫(即新建一個資料夾) 第二步:選中資料夾右鍵--Git bash here--進入控制面板,輸入命令git init 初始化化資料夾,把這個資料夾變成Git可管理的倉庫 第三步:把gitee(碼雲)上的專

Windows命令打開常用的設置頁面常用快捷鍵

evm 需要 nta perf 磁盤管理工具 管理工具 圖標 內容 alt Win+R輸入以下內容來快捷打開常用設置 compmgmt.msc # 計算機管理 diskmgmt.msc # 磁盤管理 devmgmt.msc # 設備管理 services.ms

crt遠端連線centos7 64位,Linux7檢視ip地址命令不同於6centos7網絡卡配置

首先,虛擬機器登入centos7, 1、centos7中檢視虛擬機器ip地址, 命令 ip addr ens33為虛擬機器的ip地址: 2、當然,本人在安裝centos時候已經配置了網絡卡,安裝時候沒有配置網絡卡的使用命令:vi /etc/sysconfig/network-

linux常用命令以及gccgdbvim的安裝配置

1.       linux是一個類unix作業系統       vmware--虛擬出一個硬體環境用於安裝一個作業系統       虛擬機器--在vmware中的這個虛擬的這個硬體環境/安裝的這個作業系統       xshell功能:遠端連線到虛擬機器/伺服器上堆虛擬機器

Linux安裝Nginx1.7.4php5.5.15配置

5.5 x86 針對 dsm open params 決定 最新 apt-get Nginx是一個輕量級的高性能Webserver、反向代理server、郵件(IMAP/POP3/SMTP)server,是Igor Sysoev為俄羅斯訪問量第二的Rambler.r

Linux添加防火墻iptables的安裝配置(親測)

accept verbose conf inpu wall ron -h 數據流 ack iptables基礎 規則(rules)其實就是網絡管理員預定義的條件,規則一般的定義為“如果數據包頭符合這樣的條件,就這樣處理這個數據包”。規則存儲在內核空間的信息

3Redis的安裝配置

其實在暑假的時候是配置過Redis的,但是由於當時是跟著教學視訊操作的,所以有些步驟都忘記了,所以這次直接把整個安裝和配置的過程都記錄下來,方便以後再用到的時候檢視~ Redis其實是可以安裝在Linux和windows的,都是實際應用中肯定是在Linux環境下,所以就只記錄在Lin

linux壓縮和解壓縮命令,stp本地檔案上傳下載ssh連線與傳輸

linux 上檔案解壓縮指令 tar命令   解包:tar zxvf FileName.tar   打包:tar czvf FileName.tar DirName      解壓:tar zxvf FileName.tar.gz   壓縮:tar zcvf FileName.

JDBCMySql (一)JDBC概念MySql的下載安裝

1、JDBC概念: JDBC(Java DataBase Connectivity,java資料庫連線)是一種用於執行SQL語句的Java API,它由一組用Java語言編寫的類和介面組成。 2、MySql的下載和安裝: 下載和安裝:Mysql 我是直接下載的直接安裝的版本

Axis2的下載安裝

     1.可從http://ws.apache.org/axis2/ 下載Axis2的最新版本:       可以下載如下兩個zip包:       axis2-1.5.4-bin.zip       axis2-1.5.4-war.zip       其中 axis2-1.5.4-bin.zip檔

010 Linux 下通過yumaptdnf方式安裝配置Nginx伺服器

一、安裝 Centos系統 1、安裝Nginx源。 Centos7下:#rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

job的建立配置

3.1 job型別的選擇在任意檢視下面,點選圖中的New Item如果你不能確保要選擇哪個,那就選擇構建一個自由風格的軟體專案,如果確定是maven專案那麼選擇第二項,第三項pipeline流水線後面會講到具體用法,暫不贅述3.2 job許可權控制開始配置任務了,不勾選這個,

入門級Python寫一個簡單的網路爬蟲下載獲取資料

學會如何使用API通過url(Uniform Resource Locator 統一資源定位符)連線網路,獲取網站的API獲取url儲存的API,request執行獲取的urlrequests.get(url) 定義一個變數,將API響應儲存在裡面,呼叫json將r儲存的ap

git send-email傳送patch

用 gmail 作為傳送伺服器。 為了用git send-email通過gmail伺服器傳送patch。首先編輯 ~/.gitconfig , 寫入你的賬號配置 [sendemail]smtpencryption = tlssmtpserver = smtp.gmail.comsmtpuser = [ema

利用 git format-patch git send-email 把修改的 patch 文件發送給 ffmpeg-devel

stop pass format class num false rpo orm auth 1. 下載源碼git clone https://git.ffmpeg.org/ffmpeg.git 2. 設置 git 用戶的郵箱和姓名git config --global us

命令方式啟動停止appium服務app

conf from 改名 設備 nor 啟動命令 服務啟動 logger man 啟動appium服務並監聽一個端口命令: 命令command==>  appium -a {ip} -p {port} -U {deviceName} -g {log} 以shell命令

檢視修改的歷史記錄 git log 命令 返回上一次修改版本 git reset git reflog(五)

上一篇,已經學會了修改檔案,然後再把修改檔案提交到Git版本庫,now,再重複執行一次,修改index.html檔案如下: 然後執行新增、提交: 像這樣,你不斷對檔案進行修改,然後不斷提交修改到版本庫裡,每次修改到一定程度時,再提交;一旦你把檔案改亂了,或者誤刪了檔案,還可以從最

Git常用命令

轉自阮一峰~ 我每天使用 Git ,但是很多命令記不住。 一般來說,日常使用只要記住下圖6個命令,就可以了。但是熟練使用,恐怕要記住60~100個命令。 下面是我整理的常用 Git 命令清單。幾個專用名詞的譯名如下。 Workspace:工作區 Inde

Git學習之路(三)-branchcheckoutpull命令的使用

一、branch 1、檢視遠端分支 $ git branch -a 2、檢視本地分支 $ git branch 二、checkout 1、 通過checkout建立並切換分支 $ git checkout -b v1 dev &nbs