How to generate a git patch with local commit

I am contributing to the development of an open source project that uses git as a source code repository.

After some modification of the source code, I want to generate a patch containing my signature (email address and my name) and send it to the open source project developer.

How can i do this?

+6
source share
2 answers

1) Download the source code from the git repository:

git clone git://address.of.repository/project/ /folder/path/on/my/computer 

2) Make some changes to the source code. new files / folders can be added to the project

3) provide your email address and your name for git subscription:

 git config --global user.name "Your Name" git config --global user.email you@example.com 

After that, you can fix the identifier used for this commit with:

 git commit --amend --reset-author 

4) Before committing changes. we must add new files / folders to the local git repository:

in the project folder of the source code

 git add <Newfolder> git add <Newfile> 

4) And then fix the locally modification with:

in the project folder of the source code

 commit -a 

interaction window will open

you can verify that the commit detected edited files and new files:

 # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: bin/Makefile.am # modified: configure.ac # new file: src/new.c 

under the commit -a window, you must enter a comment for your changes

and then save the commit with Ctrl + O (WriteOut), then Enter and your commit will be saved now

and then exit the commit -a window with Ctrl + X (Exit)

5) now you can create your patch with:

in the project folder of the source code

 git format-patch -1 

this will create a patch file with a name like 0001-...-...-.. .patch

If you want to create a patch using signed-off-by , just add -s :

 git format-patch -1 -s 
+6
source

Note. As for the part of git format-patch , you can (git 2.0.x / git 2.11, Q3 2014) add the signature defined in the file.

See commit 7022650 Jeremiah Mahler ( jmahler )

format-patch : add option <-- --signature-file=<file>

Add a parameter to format the patch to read the signature from the file.

 $ git format-patch -1 --signature-file=$HOME/.signature 

The format.signaturefile configuration variable format.signaturefile also be used to do this by default.

 $ git config format.signaturefile $HOME/.signature $ git format-patch -1 
0
source

All Articles