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
Can i not delete the accidentally created files without .gitignore file? how is it useful?
ReplyDelete