简体   繁体   中英

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.

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.

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 .
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM