Home > Mobile >  How do I undo the most recent local commits in Git?
How do I undo the most recent local commits in Git?

Time:12-14

I accidently commited the wrong files to Git,but didnt push the commit to the server yet.How do i undo those commits from the git.

I tried to add a question in Git but it didnt work .

CodePudding user response:

Easiest thing is to just go back to as if you hadn't committed anything:

git reset --soft HEAD~

Then you can get everything out of the index:

git reset .

And it's like you hadn't done anything.

CodePudding user response:

Git is an open-source distributed version control system (DVCS). Use this tag for questions about Git usage and workflows. Do not use this tag for general programming questions that happen to involve a Git repository. Do not use this tag for GitHub/GitHub Actions questions that do not involve git usage; use [github] or [github-actions] instead. Do not use the [github] tag for Git-related issues just because a repository happens to be hosted on GitHub.

  •  Tags:  
  • git
  • Related