Git 的patch 功能

来源:互联网 发布:项目资金管理系统 php 编辑:程序博客网 时间:2024/05/16 00:40

git patch

1. git format-patch -1

打一个当前提交的补丁,也就是最后一次的提交改动, 相当于svn diff

2.git fromat-patch -1 6525c43add803bfee37cf5c1cb573ed8aecf529e   

 打一个指定具体某一次的补丁

3.git format-patch -2 6525c43add803bfee37cf5c1cb573ed8aecf529e  

 打基于指定具体某个版本的接连两次的补丁

4.git format-patch –s HEAD~3..HEAD  //将最近3个提交转换为3个补丁文件

 -s  参数会在导出的补丁文件里面添加当前用户的签名

5. git  am mail-file  //将mbox格式的从mail 发过来的patch应用回来.

6.git apply   patch-name  //应用一般的patch,但是不能执行提交操作

Changes to be committed:

#   (use "git reset HEAD <file>..." to unstage) //reset 加--soft 会保持文件的stage状态,(to be committed,这往往是被撤消的提交中的文件,stage中的文件的修改是diff不出来的), 如果不加(默认:mixed)就会把所有mark to be committed的文件全unstage掉,这时可以diff出来该文件的改动了

#

#    modified:   packages/apps/Contacts/src/com/android/contacts/ContactsUtils.java  //不会被diff出来,

#

 

# Changed but not updated:                        //会被diff出来

#   (use "git add <file>..." to update what will be committed)

#   (use "git checkout -- <file>..." to discard changes in working directory)

#

#    modified:   frameworks/base/core/java/com/android/internal/app/RingtonePickerActivity.java

#    modified:   frameworks/base/media/java/android/media/RingtoneManager.java

#

 

# Untracked files:                                       //不会参与版本管理,除非用git add进来

#   (use "git add <file>..." to include in what will be committed)

0 0
原创粉丝点击