tags:

views:

67

answers:

2

I am about to create a patch file for a project. My branch is the "master" in my local repository. And the remote upstream branch is mapped to the local branch "origin". \ With this command I can compare the two branches and see all differences

git diff origin..master

[gives me a full patch format of all commits]

But in this case, I'd like to cherry-pick some of the commits and create a new patch file specificly for the different areas wheere my branch differs. The question is how I can see the individual commits?

+4  A: 

To just see the commits you can use

git log origin..master

You can also add the -p option to see the individual patches. If you want to cherry pick commits you can use the git rebase -i option which is pretty neat.

On your master branch:
git checkout -b create-patch-foo
git rebase -i origin

This will let you pick, edit, omit or even squash (combine) commits.

m5h
You might want to clarify that by “This will let you … merge commits.” you are referring to the ‘squash’ command in `git rebase -i`. Merge has specific meaning in version control systems that is different from the idea of ‘squash’ing diffs/patches/commits together. Maybe ‘combine’ is a less overloaded word if you do not like ‘squash’.
Chris Johnsen
Good call Chris, merge was an unfortunate choice of word for this meaning.
m5h
Thanks m5h, of course I should just use git-log and not git-diff to see the individual commits :) Perfect!
Jesper Rønn-Jensen
Great, feel free to mark the question as answered if you found the answer you asked for :)
m5h
m5h, don't worry that I will eventually mark question as answered. But doing so too hasty will prevent me from accepting a potentially better answer. :)
Jesper Rønn-Jensen
True, should have checked your accept rate as well, getting too used to people not marking as accepted :)
m5h
+4  A: 

Try git cherry A B or git log --left-right --boundary --oneline A...B.

Jakub Narębski