使用Git打包patch补丁

第一次的时候需要先创建一个本地代码库:

初始化一个新的git仓库
在一个已存在的目录中初始化git存储,只要在目录下输入'git init'命令即可。这样会为这个目录生成一个基本的git存储框架。

$ rails myproject
$ cd myproject
$ git init

现在,就有了一个空的git存储(你可以查看目录下的'.git'目录)。现在就可以stage和提交(commit)文件到这个目录了。分别使用'git add'和'git commit'命令。

$ git add .
$ git commit -m 'initial commit'

这样你就有了一个完整的提交之后的git存储了,可以运行'git log'

$ 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
输入一些提交的信息,譬如"added myself to the README as an author"然后退出。


第四步打成Patch包

git log 查看提交的id

git format-patch xxxxxxxxxxxxx(commit id)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值