Wednesday, October 14, 2015

Remove Files/ Directory from Git


To Remove a file from Git Added mistakenly

$ git rm -r --cached <wrong-file>

$ git commit -m '(deleting files added mistakenly)'

$ git push

Note :
You should always have a gitignore file like below ,so that you don't add anything accidently.
just create a new file gitignore and copy the below contents to it -

/.project
/target/
/.settings/
/.classpath
*.idea
*.iml

1 comment:

  1. Can i not delete the accidentally created files without .gitignore file? how is it useful?

    ReplyDelete