Keyur Padalia
Keyur Padalia

Reputation: 2097

How do I Git Commit all (.) except one file?

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

Upvotes: 4

Views: 7374

Answers (2)

Qurashi
Qurashi

Reputation: 1467

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/

Upvotes: 4

StenSoft
StenSoft

Reputation: 9609

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

Upvotes: 2

Related Questions