4

I'm new to Git so please bear with me. I initialized my repository and used 'git add .'

What happens if I delete a file and commit? Do I need to reuse 'git add .'? How do I ensure that when I push to master on github, the deleted file won't be there?

Delos Chang
  • 1,823
  • 3
  • 27
  • 47
  • 1
    It depends on what you mean by 'wont be there.' you can use git rm but others can still go back in the history and retrieve this file. If you committed and pushed a file with a password you'd have to rewrite your tree. There are plenty of answers on this site to tell you how to do this and the ramifications. – Andrew T Finnell Apr 10 '12 at 20:55

1 Answers1

10

Use git rm to delete a file and make Git recognize the deletion.

git rm path/to/file
git commit
git push
Andrew T Finnell
  • 13,417
  • 3
  • 33
  • 49
Amber
  • 507,862
  • 82
  • 626
  • 550
  • 1
    I deleted a bunch of files from my folder that I don't want to appear when I commit and push. Is there a way to reupdate the entire repository with the current files in the directory? Because I don't remember the names to use git rm – Delos Chang Apr 10 '12 at 21:06
  • 3
    Type `git status` and it'll show you what files are missing. You could use `git add -u` to mark all missing files as removed. – Amber Apr 10 '12 at 21:08