0

I forked/cloned apache whirr on Github, and began work on the trunk branch. During the work, I pulled two commits from origin/trunk. When I generate a patch by running a git diff first_feature_commit HEAD, I get a patch that has these two commits in it. The patch was therefore rejected when I submitted it.

How do I create a patch without the commits that I pulled from origin/trunk?

rjurney
  • 4,824
  • 5
  • 41
  • 62

4 Answers4

0

Generate the patch using git format-patch and it will split them up. You could also just make your diff with git diff HEAD^ to get only your commit (which is presumably the most recent one).

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
0
git checkout -b rj/rilly_feature
git rebase -i master
# remove spurious commits in interactive rebase file
git diff master
# observe success

This is intended to address your "failure" to create a feature branch—if you think you should be working from a feature branch, this will get you on one and allow you to generate a clean patch too.

mdcclv
  • 26
  • 4
  • Sorry, I shouldn't have said `git diff`, that will be empty in that case. Can you generate the patch you want, though? With `git diff master`? – mdcclv Sep 11 '13 at 18:38
  • The rebase is a noop. Git diff master generates nothing. – rjurney Sep 11 '13 at 18:43
  • Does that mean that creating a branch and rebasing discarded your changes? Or what is in `git log`? – mdcclv Sep 11 '13 at 20:22
0

1) Add a remote to the repository you are interested in patching. Probably something like

git remote add upstream https://github.com/apache/whirr.git

2) Fetch the remote. Just get all of them probably:

git fetch --all

3) Make your patch!

git diff upstream/trunk..HEAD >my.patch

HTH! @eldondev

Eldon
  • 1
0

When you want to get only those commits that are in your master branch and not on origin/master (the server) you can get those with

git diff origin/master..HEAD

For more details please see Git Tools - Revision Selection of Pro Git.