Search code examples
gitgit-mergegit-tag

git force merge - Already Up To Date


Is it possible to merge a tag to a branch when the changes are already incorporated into the branch? I'm trying to populate the Precedes line in gitk

Edit: When I do git merge <TAG> it fails to merge since the branch doesn't have any differences.

Edit2: We are using a gitflow process where we have master, develop, and PTR branches. Our process is to make a release branch from develop. Once tested the release branch is squashed and merged to master. The squashed commit is tagged on master. Then tag is then merged back to the release branch and then merged to develop. The issue we're running into is commits on release do not Precede the tag. It makes it difficult to verify if a commit was part of a build


Solution

  • when the changes are already incorporated into the branch?

    That means:

    -x--x--x--x--x (master)
             /
     -y--y--y--y--y (abranch)
            |
         (tagT)
    

    Since the tag reference a commit which was already merged to master, ant git merge <atag> will be a no-op.
    And the tag won't be part of the master branch, it remains part of abranch.

    That means git branch --contain <aTag> won't include master.
    See also "Verify if a tag was done in the master branch".


    In the new gitflow context provided by the OP:

    Our process is to make a release branch from develop.
    Once tested the release branch is squashed and merged to master
    The squashed commit is tagged on master

                     (aTag)
                       |
       -m--m--m--m--m--R (master, with release squashed-commit)
             
         r--r--r--r (release)
        /
    -d--d--d (develop)
    

    Then tag is then merged back to the release branch and then merged to develop

                     (aTag)
                       |
       -m--m--m--m--m--R   (master, with release squashed-commit)
                        \------------\
         r--r--r--r-----r' (release)  \
        /                              \
    -d--d--d---------------------------d' (develop)
    

    The issue we're running into is commits on release do not Precede the tag. It makes it difficult to verify if a commit was part of a build

    From the schema:

    Then that commit is part of the "aTag" build.

    The problem, indeed:

    The problem is in gitk, r1,r2,r3,r4 do not show a Precedes: <tag> that was merged in r'

    I agree. Gitk won't be able to show that tag.
    I would put a tag to r', with a similar name as aTag, in order to get a better idea of the "Precedes" part in Gitk.