Wrong files added in commit

Mon 19 March 2018 by Aditya Arora

This post helps users to revert changes made while using git. We might add wrong files while committing. It is a good practice to use

git status

to check what files are currently worked on. So this is what you have done

  • Added the wrong files to the staging area
  • Commited
  • Not push

What to do now?

  • Reset to the last commit
git reset --soft HEAD~1
  • Remove folders that you dont want
git reset node_modules/
  • Check status to see the added files in the staging area
git status
  • Make new commits
git commit -m "Cleaning styles.css"
  • Push the commits
git push -u origin master

Comments