0

I am still new to git and I am trying to use the git with java. So, I have a java file and inside this file, I started providing print statements and commit each time I finish a print statement to be able to use the git revert. So, let's say: - The first commit: I added my name - The second commit: I added my job - The third commit: I added my address Hence, here in each version of the code I have a print statement added to my java code.

Now, when am trying to revert the second commit using: git revert while providing the commit id of the second commit, it's telling me that I have conflicts that I should resolve, knowing that I haven't changed anything in the subsequent commits after commit #2, I just added print statement for third commit.

All what I need to do is to try to use the git revert to remove the second commit and have a version containing the first and last print statements.

Please if could anyone help in this matter, thanks!

  • Welcome to StackOverfkow. You'd probably have to share your commits to get a more specific advice, but I guess that your third commit made changes in lines very close to those of the changes in the second commit that you want to revert, so git cannot figure out automatically what to do and therefore asks for your help. – Manfred Jan 28 '23 at 13:24
  • Also: what's your actual question? _"How to Resolve conflicts when I do git revert?"_ – Get your file to the state you want it to have, `git add` the changes and then `git commit`. – Manfred Jan 28 '23 at 13:28
  • 1
    As your question is not actually related to `java` nor to `github`, I suggest to remove these tags. – Manfred Jan 28 '23 at 13:29
  • Does this answer your question? [How do I resolve merge conflicts in a Git repository?](https://stackoverflow.com/questions/161813/how-do-i-resolve-merge-conflicts-in-a-git-repository) – 1615903 Jan 30 '23 at 04:37

0 Answers0