Create and apply patches
A patch is a file that carries changes from one repository to another. GitTree saves a file’s changes or one or more commits as a patch, and applies a patch to your working tree, staged, or as commits on the current branch.
Works in GitTree Free: every local Git feature, once you are signed in.
On this page
Before you start
- For applying: finish or abort any merge or rebase in progress.
Where to find it
- Right-click a changed file: Create Patch from File Changes….
- Right-click a commit: Create Patch from Commit…; or select several and choose Create Patch from Commits….
- The command palette: Apply Patch….
| Action | macOS | Windows and Linux |
|---|---|---|
| The command palette, then Apply Patch… | ⌘⇧P | Ctrl+Shift+P |
Steps
Save a patch
Choose one of the create actions and pick where to save the file. GitTree says Saved the commit as a patch. (or how many commits).
Apply a patch
Run Apply Patch… and choose the file. GitTree says how many files and commits it holds, and whether it includes binary changes.
Choose how to apply it
Under Apply to, choose Working tree only, Working tree and stage the changes, or As commits on the current branch (only for a patch saved from commits). Press Apply.
Expected result
The changes are in your working folder, staged, or committed with their original messages and authors.
Which way to apply?
| Choice | Like |
|---|---|
| Working tree only | git apply |
| Working tree and stage the changes | git apply --index |
| As commits on the current branch | git am |
If something goes wrong
“This patch cannot be applied any of these ways.”
The files it changes differ too much from yours. Apply it on the branch or commit it was made from.
“Stopped on a conflict: resolve it, then continue.”
Resolve the conflicted files and continue from the banner (resolve merge conflicts).
Questions
Patch or branch?
When both people can reach the same remote, push a branch. A patch suits sending a change by e-mail or to a repository you cannot push to.