使用Git打包patch補丁
阿新 • • 發佈:2019-01-24
第一次的時候需要先建立一個原生代碼庫:
初始化一個新的git倉庫
在一個已存在的目錄中初始化git儲存,只要在目錄下輸入'git init'命令即可。這樣會為這個目錄生成一個基本的git儲存框架。
$ cd myproject
$ git init
現在,就有了一個空的git儲存(你可以檢視目錄下的'.git'目錄)。現在就可以stage和提交(commit)檔案到這個目錄了。分別使用'git add'和'git commit'命令。 $ git add .
$ git commit -m 'initial commit'
這樣你就有了一個完整的提交之後的git儲存了,可以執行'git log'
第二步檢視修改
git diff xxxx
第三步提交修改
執行 'git commit -a' 命令,效果跟在SVN中使用'commit'命令一樣。
$ git commit -a 執行完之後,一個提交資訊的提示會出現在編輯器中(這裡$EDITOR環境變數或'core.editor'這兩個git配置變數的預設值都是vim)類似下面這樣的內容: _# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch main
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: README
#
~
~
".git/COMMIT_EDITMSG" 9L, 253C
第四步打成Patch包
git log 檢視提交的id
git format-patch xxxxxxxxxxxxx(commit id)