Bill
Bill

Reputation: 132

Git when file is deleted from repo

I am looking to make a script to do the following. I am assuming I am going to have to write a script Here is what I need it to do. If a file is deleted from the working copy of the repository, remove it (git rm) from the next commit. Add all changes in the working copy to the next commit.

Upvotes: 0

Views: 31

Answers (2)

Bill
Bill

Reputation: 132

Something about articulating question helps me work it out. Here is the answer.

git-stage-all(){
   if [ "`git ls-files -d | wc -l`" -gt "0" ]; then; git rm --quiet `git ls-files -d`; fi
   git add .
}

Upvotes: 0

Schwern
Schwern

Reputation: 165145

git add -u will stage all changes to all tracked files. This includes modifications and deletions.

git add -A will do the same thing, but it will also stage untracked files.

Upvotes: 2

Related Questions