Reputation: 1054
We have a following GIT "working habit". I will shortly describe it to clarify the context of my later question.
We work with three permanent branches (DEV,STAGE,MASTER). In general STAGE should be in sync with MASTER. But DEV is allways considered as "dirty" which means it can contain lot of commits which never get merged into STAGE or MASTER. We only merge feature branches or single commits from DEV into STAGE. Then we merge STAGE into MASTER.
Now at some point we started a huge "change set" (major project upgrade) and created a dedicated feature branch, say UPGRADE for this. The work on this feature was going on for 3 months.
Now I would like to merge that huge feature branch into STAGE but I am not 100% sure if I created the branch UPGRADE from STAGE/MASTER or from DEV. We did not document this.
Since DEV is "dirty" I can not do the merge if UPGRADE was branched from DEV!
So here is my problem: Now I would like to be sure that we branched UPGRADE from STAGE/MASTER and not from DEV (I should have taken STAGE/MASTER but I am not sure now). How can I fetch the most reliable informations from the repositry?
I did already some research and tried to use "git merge-base". Here are the three commands I tried.
1) git show --summary 'git merge-base upgrade dev'
2) git show --summary 'git merge-base upgrade stage'
3) git show --summary 'git merge-base upgrade master'
But they all deliver the same treeish which is only a few days old.
So here my question again: Now I would like to be sure that we branched UPGRADE from STAGE/MASTER and not from DEV. How can I fetch the most reliable informations from the repositry?
Upvotes: 0
Views: 44
Reputation: 38096
The easier way is to use any of the below command:
git log --oneline --decorate --graph --all
gitk --all
You can view the branch structure apparently. Such as there has master
and new
branch in below graph, and we can find new
branch is created from master
branch. You can use the same way to find where UPDATE
was created from.
* 0d04f17 (HEAD -> master, origin/master, origin/HEAD) 5
* 74d5ed3 5
* 6146194 4
* e5ddeac 3
* a33f9ee 2
* 8373f5d hi1
* 3df7047 hi
* 3f27319 6
| * f0cca03 (new) 1
|/
* 38236ae Update config
UPDATE
branch to a past commitAssume UPDATE
branch is created from DEV
branch, the past commit is commit D
and the commit history looks like:
A---B---C---D---E master
\
F---G---H---I DEV
\
J---K---L UPDATE
1.Rebase UPDATE
directly (don’t keep the original UPDATE
branch):
git rebase --onto <commit id for D> DEV UPDATE
Then the commit history will like:
J'---K'---L' UPDATE
/
A---B---C---D---E master
\
F---G---H---I DEV
2.Rebase changes of UPDATE
to a new branch and keep the original UPDATE
branch:
git checkout -b new <commit id for D>
git rebase --onto new DEV <commit id for L>
git branch -f new
git checkout new
Then the commit history will like:
J'---K'---L' new
/
A---B---C---D---E master
\
F---G---H---I DEV
\
J---K---L UPDATE
Upvotes: 1