![]() Hint: Waiting for your editor to close the file. Initialized empty Git repository in E:/tut_repo/.git/ This scenario is illustrated below- $ MINGW64 /e/tut_repo The following command will undo changes made by the faulty merge and create a new commit that will replicate the first parent – c2. In our example, the faulty merge has two parents c2 of the master branch is the first parent and C4 of the feature branch is the second parent. The -m option is used to specify the parent commit that the new commit should replicate. To revert the merge commit we should tell git how we want it to revert the changes. This is because, the merge commit has two parents - one parent on the master branch and other on the feature branch. The -m flag in the above command is mandatory and should be followed by a number greater zero. The syntax for using the revert command is $git revert -m HEAD Unlike the reset command, the git revert command will invert changes introduced by the faulty merge commit and create a commit which will replicate a desired commit. ![]() We will not use the git reset command to revert the faulty merge as the faulty merge is shared and we do not want to rewrite the history. Let us assume that project compilation fails due to a faulty merge. The commits in the feature branch the ( C3 and C4) are merged into the master branch and the resulting commit is shared. Both the branches are diverged and have two commits each. ![]() In situations like these we need to undo the merge using the git revert command.Ĭonsider the following diagram, where the repository has two branches – master and a feature branch. This happens if we make mistakes while merging. Let us say we performed a merge commit, shared this commit and later found out that the code is not compiling or our application is not working.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |