What's the best way to update a module and commit with git?

Currently I'd use drush pm-updatecode then inspect with git status. The problem then is there are many files that have changed, been added or been deleted. Then performing an add or rm on the right files seems a bit cumbersome.

Would it be better to first do rm on the module, commit, then drush dl, add, commit?

3 Answers 3


git add -A is the simple answer you are looking for. It will add all of the files anywhere inside the current working directory, including any new files that were provided or removed pm-updatecode. (Note: git add . behaves similarly to git add -A, except that it will not include removed files in the commit.)

There is one inconvenience with git add -A, though, and that is that if you have any stray files in the way, they will be added to the repository as well (obviously enough). You can get around this problem by listing the files that should never be committed in a .gitignore file, or simply use git reset HEAD unwantedfile prior to git commit, as recommended by git status.

drush will manage this for you with the --version-control=svn option, but as you may surmise, this is only useful when you project is checked in to svn. As of yet, no one has written --version-control=git. This was discussed in http://drupal.org/node/797190, but closed "won't implement". There are some other good git commands to try in that thread as well.


If you are updating the Views module for example, you can do the following:

drush up views
git add /sites/all/modules/views
git commit -m 'views update'

This way only the changes in your views folder will be added to staging before commit.

  • 2
    This is essentially correct, but will miss files removed in the update. Commented Aug 21, 2012 at 5:51
  • So the second line should be git add -A /sites/all/modules/views ?
    – Nic
    Commented May 9, 2016 at 10:05
git rm -r module
drush dl module
git add module
git commit -m "Upgrading module"
git push origin master
  • Please explain your steps in greater detail. Commented Nov 2, 2013 at 0:00
  • This would pollute the git database in the case where most files where unchanged
    – Nic
    Commented May 9, 2016 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.