0

I have a repository where I have a commit I would like to publish as a patch to an open source project. The problem is that some parts of that commit have debugging information I need and want to keep for myself, but represent clutter to this public repository.

What I am looking for is to produce a patch file from my repository through a similar mechanic as the git add -up, where I can select which parts of the differences are going to be staged for commit. Is there any way to this to produce a patch I can send?

7ochem
  • 2,183
  • 1
  • 34
  • 42
Paulo Neves
  • 1,096
  • 14
  • 22

2 Answers2

1

You could just use git add -up:

  • Check out a new branch based on your work.

  • Reset it back to the parent of your work, e.g., something like git reset master. This will rewind the repository without making changes to your working copy.

  • Now use git add -up to add your changes.

  • Commit the changes, and now you can git format-patch master to get your patch.

larsks
  • 277,717
  • 41
  • 399
  • 399
1

Is there any way to this to produce a patch I can send?

Sure. Commit what you have, create a new branch based on your current branch (like git checkout -b NewBranchName) and edit out the parts you don't want to publish. When you're ready, consider rebasing to squash your commits down to just one commit, and then create a pull request from NewBranchName. Then you can go back to your previous branch and still have all the debug stuff intact.

Caleb
  • 124,013
  • 19
  • 183
  • 272