Pergunta

I made some changes inside ServiceImpl.java and when i was about to commit in repository it shows me you had some changes in .project file. The changes are...

<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
    </buildCommand>
     <buildCommand>

and by mistake I commited it in repository, And I saw some conflict error.
I removed the code from project` file! and recommit it, and i saw the same error again!

The problem is I have done many commits since then.
How would I cancel this faulty commit?

Foi útil?

Solução

If your commit consisted of only the one file, you could do a:

git reset --hard HEAD~

That will bring you back to the state before your last commit.

Make sure you don't have any other modifications in progress though (or stash them first).


The OP Akash adds though in the comments:

i did commit manytimes

You have tow choices:

  • a git rebase --interactive let you reorder past commits, including dropping the one you don't want.
    That changes the history though, meaning you will need a git push -force (if you did already push those commits before): if you are pushing to a pull request branch, this ok. If you are pushing to a public branch (cloned by other), that can be problematic.

  • a git revert (see "Revert to previous Git commit"), in order to create a new commit which will cancel the modification of the past commit.
    This is safer, and doesn't change the history.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top