How to do it...

On the develop branch, we have just checked that there is a merge commit that introduces hello world programs from languages that start with P.

Unfortunately, the Perl version doesn't run:

$ perl hello_world.pl 

Can't find string terminator '"' anywhere before EOF at hello_world.pl line 3. 

The following steps will help you revert a merge:

  1. Let's take a look at the history, the latest five commits, and find the merge commit:
$ git log --oneline --graph -5 
* a95abc6 Adds Groovy hello world 
*   5ae3beb Merge branch 'feature/p-lang' into develop 

| 
| * 7b29bc3 php version added 
| * 9944417 Adds perl hello_world script 
* | ed9af38 Hello world shell script 
|/

The commit we are looking for is 5ae3beb Merge branch 'feature/p-lang' into develop; this adds the commits for hello world in Perl and PHP to the develop branch. We would like the fix of the Perl version to happen on the feature branch, and then merge it to develop when ready. In order to keep develop stable, we need to revert the merge commit that introduced the faulty Perl version. Before we perform the merge, let's just have a look at the content of HEAD:

$ git ls-tree --abbrev HEAD 

100644 blob 28f40d8    helloWorld.groovy 
100644 blob 881ef55    hello_world.c 
100644 blob 5dd01c1    hello_world.php 
100755 blob ae06973    hello_world.pl 
100755 blob f3d7a14    hello_world.py 
100755 blob 9f3f770    hello_world.sh 
  1. Revert the merge, keeping the history of the first parent:
$ git revert -m 1 5ae3beb 

[develop e043b95] Revert "Merge branch 'feature/p-lang' into develop" 

 2 files changed, 4 deletions(-) 
 delete mode 100644 hello_world.php 
 delete mode 100755 hello_world.pl 
  1. Let's have a look at the content of our new HEAD state:
$ git ls-tree --abbrev HEAD 

100644 blob 28f40d8    helloWorld.groovy 
100644 blob 881ef55    hello_world.c 
100755 blob f3d7a14    hello_world.py 
100755 blob 9f3f770    hello_world.sh 

The Perl and PHP files introduced in the merge are gone, so the revert did its job.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.199.243