Search code examples
gitgit-addgit-rmgit-stage

“git rm .” is not adding the deleted files in the staged area


I eliminated some files of my project. I want to pass all the eliminated files to staging area with some as git rm ., but I want to pass all the files at once using wildcards.

What's the good way to stage the eliminated files?

fernando@fernando:~/ProyectoTicketMaster/Ticket_Master$ git status
# On branch jquery
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   deleted:    app/assets/javascripts/bus_routes.js.coffee
#   modified:   config/routes.rb
#
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   deleted:    app/assets/javascripts/schedules.js.coffee
#   deleted:    app/assets/stylesheets/bus_routes.css.scss
#   deleted:    app/assets/stylesheets/schedules.css.scss
#   deleted:    app/controllers/bus_routes_controller.rb
#   deleted:    app/controllers/schedules_controller.rb
#   deleted:    app/helpers/bus_routes_helper.rb
#   deleted:    app/helpers/schedules_helper.rb
#   deleted:    app/models/bus_route.rb
#   deleted:    app/models/schedule.rb
#   deleted:    app/views/bus_routes/_form.html.erb
#   deleted:    app/views/bus_routes/edit.html.erb
#   deleted:    app/views/bus_routes/index.html.erb
#   deleted:    app/views/bus_routes/new.html.erb
#   deleted:    app/views/bus_routes/show.html.erb
#   deleted:    app/views/schedules/_form.html.erb
#   deleted:    app/views/schedules/edit.html.erb
#   deleted:    app/views/schedules/index.html.erb
#   deleted:    app/views/schedules/new.html.erb
#   deleted:    app/views/schedules/show.html.erb
#   deleted:    db/migrate/20141223030318_create_bus_routes.rb
#   deleted:    db/migrate/20141231211702_create_schedules.rb
#   deleted:    test/fixtures/bus_routes.yml
#   deleted:    test/fixtures/schedules.yml
#   deleted:    test/functional/bus_routes_controller_test.rb
#   deleted:    test/functional/schedules_controller_test.rb
#   deleted:    test/unit/bus_route_test.rb
#   deleted:    test/unit/helpers/bus_routes_helper_test.rb
#   deleted:    test/unit/helpers/schedules_helper_test.rb
#   deleted:    test/unit/schedule_test.rb

Solution

  • In git you add deletions.

    git add -u

    Will update your index, taking into account only files that are already present in your history. Therefore it will take into accounts modifications and deletions but not new files.