tags:

views:

70

answers:

2

I have added a file says "file1.txt" to git repo. After that I committed it and add few directories says dir1 and dir2 and committed to git repo. Now the current repo has a file1.txt and dir1 and dir2 . How to delete file1.txt without affecting others like dir1 and dir2.

+4  A: 

Use git rm:

git rm file1.txt
git commit -m "remove file1.txt"
Greg Hewgill
Thanks Greg!! It's worked fine.
lakshmipathi
+2  A: 

More generally, git help will help with at least simple questions like this:

zhasper@berens:/media/Kindle/documents$ git help
usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]

The most commonly used git commands are:
   add        Add file contents to the index
   :
   rm         Remove files from the working tree and from the index
James Polley
james...instead of checking --help , I googled about it and found things like filter- or creating temporary braches etc etc and got confused. :) .
lakshmipathi
For more complex things, I find `git help` confusing, but it's good for the simple things :)
James Polley