Made a mistake with committing...

Hi, I found a bug while solving one of the issues and I fixed the bug, but I have committed the code to the branch in which I was solving the issue. How do I commit that file which has the bug to a new branch?

Thanks in advance..

There are two options.

  1. Simply create a new branch off of your master branch and commit the fix there.

  2. If (and only if) you fixed the bug in a commit by itself; you can use the git cherry-pick command, which takes a commit from one branch and applies it to another.

Usually 1 is easier to do and that’s what I would recommend.

Thanks a lot, I have committed the files to a new branch and have made a pull request..