@amrit_padda out of curiosity, do you have your changes in a fork of the original openemr repository that branched off a 5.0.2 version such as GitHub - openemr/openemr at rel-502?
The git merge-base
command is really useful for finding the common base after branching. From there, you can also see if there are commits in the rel-502 branch that aren’t in master (and not strictly in any of the rel-* branches after 502). You can also use a tool like gitk
to visualize the flow of commits from the current commit to a more modern version.
For me:
$ git merge-base upstream/rel-502 upstream/master
43827b53658796af2996b48e63a97f6bcc64dc87
$ git log -1 $(git merge-base upstream/rel-502 upstream/master)
commit 43827b53658796af2996b48e63a97f6bcc64dc87
Author: Brady Miller <brady.g.miller@gmail.com>
Date: Sun Jul 14 13:06:08 2019 -0700
remove unused Filtreatment class (#2559)
$ git log --oneline $(git merge-base upstream/rel-502 upstream/master)...upstream/rel-502 | wc -l
171
showing there are 171 commits from when 502 diverged from master. These are for patching, of course. Specifically:
$ git log --oneline --decorate=full $(git merge-base upstream/rel-502 upstream/master)...upstream/rel-502 | grep -F '(tag: '
babec93f6 (tag: refs/tags/v5_0_2_4) Final 502 batch payments. Yeah right! (#3828)
672120934 (tag: refs/tags/v5_0_2_3) prepping for patch 3 release
94409d012 (tag: refs/tags/v5_0_2_2) patch sql fix
728f4bdd4 (tag: refs/tags/v5_0_2_1) typo reported and fixed in forum (#2716)
35a67d115 (tag: refs/tags/v5_0_2) 5.0.2 sql upgrade fixes
The patch commits should actually reflect changes that did make it into master, but because the base is different, they show up differently and may make it a bit confusing to follow the trail of changes. That’s why it’s useful to know where the merge base is.
Another useful tool is the git cherry
command, which can tell you if commits in a branch have also been applied to another branch. The command outputs a list of commits prefixed with -
when an equivalent commit is in upstream, and +
when the commit has not been applied to upstream.
$ git cherry upstream/master upstream/rel-502 | grep -c '^-'
84
So you can use this to identify which of the 170 commits in rel-502 that are not shared with master are effectively in master after branching.
Ultimately, if your fork is not very different from core, then it’s probably easiest to encapsulate your changes and then re-apply them after updating, especially if your fork doesn’t include database changes. But since this post is about using git to check the changes, I thought it’d be useful for me to talk about git merge-base and cherry.