4

Hi all I have done git rm on few files and have modified one file. I want to know how can I do git commit . to commit deleted files with excluding the modified file.

Is there anything like

git commit -m "Files deleted" . -exclude scripts/process_old_FBA_orders.php 

Below is my git status

Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: help/he_about.html deleted: help/he_glossary.html deleted: help/he_index.html deleted: help/he_jadmin/ad_index.html deleted: help/he_jadmin/ad_server_info.html deleted: help/he_jadmin/ad_users.html deleted: help/he_orders/or_index.html deleted: help/he_products/pr_index.html deleted: help/he_reports/re_index.html deleted: help/he_setup/se_index.html deleted: help/he_stock/st_index.html deleted: help/he_stock/st_needed_items.html deleted: help/he_stock/st_purchase_orders.html deleted: help/he_stock/st_stock_orders.html deleted: help/he_stock/st_stocked_items.html deleted: help/he_stock/st_suppliers.html deleted: help/he_stock/st_suppliers_items.html Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: scripts/process_old_FBA_orders.php 
3
  • 2
    just commit, your modified file is not staged Commented Feb 9, 2015 at 15:13
  • Just to mention, git commit -m 'some message' is generally a bad idea, with or without specifying paths to commit. A good commit message usually won't fit on a single line. :P And letting the editor fire up also lets you see what's about to be committed. Commented Feb 9, 2015 at 15:15
  • You want to commit deletion of help files, but not changes in scripts? In this case you could simply do git commit -m 'Files deleted' help/ Commented Feb 9, 2015 at 15:16

2 Answers 2

4

If its only one or two files I see its easy to add all files then reset unwanted files.

$ cd /path/to/repo $ git add . $ git reset /path/to/unwanted/file $ git commit -m 'commit message' 

You can reset a whole directory $ git reset /path/to/directory/

Sign up to request clarification or add additional context in comments.

Comments

2

Just run git commit -m "Files deleted". Changes not staged for commit (as specified in git status) are not committed.

1 Comment

This answer is technically correct, but only applicable to the exact situation the OP ran into. I.e. it is not a generic answer and dependent on a state similar to what the OP has: a set of deleted files and one changed file. IF it were trying to answer the more generic title, then it would be missing information to be complete.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.