When you modify your settings.py file of your Django project on production servers you can get errors like this when updating the code:
$ git fetch $ git merge origin/master ... error: Your local changes to 'settings.py' would be overwritten by merge. Aborting. Please, commit your changes or stash them before you can merge. ...
The best solution I’ve found was using the stash, a temporary location where you can save your changes to recover them later, resetting your branch to put it in a clean state.
$ git stash save "My local settings.py prod changes"
Saved working directory and index state On master: My local settings.py prod changes
HEAD is now at a318301 That commit message
$ git merge origin/master
Merge made by recursive.
...
5 files changed, 219 insertions(+), 28 deletions(-)
...
$ git stash list
stash@{0}: On master: My local settings.py prod changes
$ git stash apply
Auto-merging settings.py
...
$ git stash drop
Dropped refs/stash@{0} (c00440c6a495cffd2f69de172faf6371c28058cf)
And your changes are back again!
One Comment on “Git & Django’s settings.py problems in production servers (I)”
You can track this conversation through its atom feed.
It’s easier using this way:
$ git stash
$ git stash pop
Posted on October 18, 2011 at 12:52 pm.