Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gerrit Format Patch

Tags:

git

gerrit

What is the difference between gerrit "Format Patch" and "Checkout" options ? Basically I want all changes of a commit to my local directory without making a new commit in my local repo.

like image 554
DEVAS Avatar asked Sep 11 '25 20:09

DEVAS


1 Answers

Both call git fetch <url> refs/changes/xx/xxx/xx first to get the history of the change.

Format Patch then calls git format-patch -1 --stdout FETCH_HEAD. It generates a patch of the current patchset of the change to stdout. You can redirect it to a local file or remove --stdout so that a patch named 0001-xxxx.patch will be created.

Note that if you are going to send the patch to another person or if you are going to apply the patch in another repository, it's better to append --binary to git format-patch, so that you don't have to consider if the commit changes any binaries. The repository where the patch is applied may not have necessary data of these binaries, which will make the apply fail. With --binary, the necessary data are also included in the patch.

Checkout then calls git checkout FETCH_HEAD. It switches the local code to the revision of the current patchset of the change and results in detached HEAD state.

If you want to introduce the changes of the commit to the local branch, you can paste the command of Cherry Pick and append the option -n and then run it. Another way is to run the command of Format Patch without --stdout first, and then run git apply -3 0001*.patch.

like image 104
ElpieKay Avatar answered Sep 14 '25 11:09

ElpieKay