I want to use git cherry
to show all commits that went to a specific branch but are missing from the master branch and log this using pretty format.
I tried this:
git cherry master branch_name | grep "^+" | sed 's/^+ //' | xargs -I {} git --no-pager log --pretty=format:'%h,%an,%d,%ae,%ad,%s' --date=short -1 {}
What this does is to:
git cherry master branch_name
- list in the terminal line by line all hashes of commits that have code in branch_name and not in master and the other way around with a + or a - sign before the hash.grep "^+"
- get only those that start with a + (the ones missing in master from branch_name actually)sed 's/^+ //'
- remove the+
from the line so we can get only the hash.xargs -I {} git --no-pager log --pretty=format:'%h,%an,%d,%ae,%ad,%s' --date=short -1 {}
- passes each hash as a parameter to git log to show the formatted log of each hash. Here--no-pager
mean to exit git log window and-1
to show only 1 commit.
The problem with this is that it starts concatenating each result for each hash returned from git cherry on the same line. It doesn't execute it line by line so I can copy paste them or so I can save them to a csv file using ... > tmp.csv
.
Not sure if there is anything else I can use apart for xargs
or if that is actually a problem with git log and this won't work.
What am I missing? and what am I doing wrong?
Thank you all and sorry for being a noob.