1

I was trying to revert my last merge commit in my local branch and followed the below command as per This

Here I created new branch apitest/OEES-3752-containerisation-api-tests off apitest/OEES-3752-containerisation-api-tests first, below is the logs of newly created branch

Logs:

λ git log
commit 337c26b49f5a7782917e42b20722363fc38a7ba4 (HEAD -> apitest/OEES-3752-containerisation-api-tests, origin/feature/OEES-3752-release-api-test, feature/OEES-3752-release-api-test)
Merge: 97613fea1 00b69975c
Author: xxxxxx
Date:   Fri Mar 19 11:34:31 2021 +1100

    Merge branch 'develop/app' of https://github.servicexxxxxx into feature/OEES-3752-release-api-test

commit 97613fea1b4879caa4131f58be10535ac7a7a25a
Author: xxxx
Date:   Thu Mar 18 08:14:40 2021 +1100

    OEES-3752 Reverted back changes done for pipeline testing

Command:

Repo\app (apitest/OEES-3752-containerisation-api-tests)
λ git revert -m 1 337c26b49f5a7782917e42b20722363fc38a7ba4
Already up to date!
On branch apitest/OEES-3752-containerisation-api-tests
nothing to commit, working tree clean

Further;

c:\Repo\app (feature/OEES-3752-release-api-test -> origin)                                               
λ git show --name-only 337c26b49f5a7782917e42b20722363fc38a7ba4                                             
commit 337c26b49f5a7782917e42b20722363fc38a7ba4 (HEAD -> feature/OEES-3752-release-api-test, origin/feature/
OEES-3752-release-api-test, apitest/OEES-3752-containerisation-api-tests)                                   
Merge: 97613fea1 00b69975c                                                                                  
Author: xxxx                                                              
Date:   Fri Mar 19 11:34:31 2021 +1100                                                                      
                                                                                                            
    Merge branch 'develop/app' of https://github.servicexxxxxx/app into feature/OEES-3752-release-api-test                                                                                                     

Perhaps this explain more.. enter image description here

What am I missing here?

Shabar
  • 2,617
  • 11
  • 57
  • 98

1 Answers1

1

There is nothing to revert

Already up to date!

This message indicates that reverting the merge would change no files. As there's nothing to do, no revert commit is created and git exits with no action taken.

Example/Reproduction

Consider the following sequence of commands:

$ cd /somewhere/new
$ git init
(main) $ echo "something" > README.md
(main) $ git add README.md
(main) $ git commit -m 'adding the readme'

At this stage there is only one commit on the main branch.

(main) $ git checkout -b demo
(demo) $ echo "something else" > README.md
(demo) $ git commit -m 'updating the readme' README.md
(demo) $  echo "something" > README.md
(demo) $  git commit -m 'changed my mind, updating the readme again' README.md

Now let's merge that to main:

(demo) $ git checkout main
(main) $ git merge --no-ff demo

At this stage our commit history on main looks like so:

*   9173254 (HEAD -> main) Merge branch 'demo'
|\
| * ab5b344 (demo) updating the readme again
| * d85f18a updating the readme
|/
* 6d39376 adding the readme

There is a merge commit, but it doesn't contain any material changes:

(main) $ git show --name-only HEAD
commit 91732542644735d93e2a42e4ad28110669fa9b27 (HEAD -> main)
Merge: 6d39376 ab5b344
Author: Me <me@example.com>
Date:   Wed Mar 24 10:14:17 2021 +0100

    Merge branch 'demo'

(note the absence of a list of file names at the end)

Attempting to revert that doesn't result in any changes to tracked file contents:

(main) $ git revert HEAD -m 1
Already up to date!
On branch main
nothing to commit, working tree clean

Consequently there is also no revert commit created:

*   9173254 (HEAD -> main) Merge branch 'demo'
|\
| * ab5b344 (demo) updating the readme again
| * d85f18a updating the readme
|/
* 6d39376 adding the readme

In this example the merge commit was intentionally fabricated to contain no changes but it can occur under normal circumstances for a variety of reasons, such as pulling the changes from branch a into branch b, merging branch b to main, and then merging branch a to main.

AD7six
  • 63,116
  • 12
  • 91
  • 123