Skip to content
GitTree
Changes and commits

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.

FreeUpdated

Works in GitTree Free: every local Git feature, once you are signed in.

On this page
  1. Before you start
  2. Where to find it
  3. Steps
  4. Expected result
  5. Which way to apply?
  6. If something goes wrong
  7. Questions
  8. Related

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….
ActionmacOSWindows and Linux
The command palette, then Apply Patch…⌘⇧PCtrl+Shift+P

Steps

  1. 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).

  2. 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.

  3. 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?

The ways to apply a patch
ChoiceLike
Working tree onlygit apply
Working tree and stage the changesgit apply --index
As commits on the current branchgit 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.