effkay / blazing

painless git push deployments for everyone

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git reset happens twice when switching deployed branch

marcoribi opened this issue · comments

git push production
Counting objects: 966, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (392/392), done.
Writing objects: 100% (723/723), 247.83 KiB, done.
Total 723 (delta 513), reused 454 (delta 327)
remote: ------
remote: ------ [blazing] ENTERING POST RECEIVE HOOK FOR: production
remote: ------
remote: ------> [blazing] Doing a hard reset and checking out refs/heads/development since thats what you pushed
remote: HEAD is now at 30216cd add dummy commit
remote: Previous HEAD position was 30216cd... add dummy commit
remote: HEAD is now at 18fed9c... add time ago in words for latest activities
remote: ------> [blazing] Doing a hard reset and checking out refs/heads/master since thats what you pushed
remote: HEAD is now at 18fed9c add time ago in words for latest activities
remote: Previous HEAD position was 18fed9c... add time ago in words for latest activities
remote: HEAD is now at e023f74... solve merge conflicts
remote: ------> [blazing] Loading rvmscripts from custom location
remote: ------> [blazing] Loading rvm from .rvmrc
remote: Using: /opt/rvm/gems/ruby-1.9.3-p0@evz
remote: ------> [blazing] Bundling gems
remote: ------> [blazing] Running recipes for production
remote: ------> [blazing] INFO : precompiling assets
remote: mkdir -p /home/usr/evz/public_html/public/assets
remote: cp -r /home/usr/evz/public_html/vendor/bundle/ruby/1.9.1/gems/tinymce-rails-3.4.9/vendor/assets/javascripts/tinymce /home/usr/evz/public_html/public/assets
remote: ------> [blazing] running RAILS_ENV=production bundle exec rake post_deploy
remote: Running migrations if necessary
remote: Restating thin servers
remote: Notifying Campfire
To evz@scrcpt2.nine.ch:/home/usr/evz/public_html
30216cd..18fed9c development -> development
08ae27d..e023f74 master -> master

that was a wrong issue id in commit msg 😊

So, this happens because git is pushing all matching branches when no branch is specified and we loop over the pushed branches so to say. Really, there is no way to know which branch you wanted to deploy if multiple branches are pushed.

Suggested Solution when multiple branches are pushed: Stay in the currently "deployed" branch and don't execute the hook code for the other branches.

Meanwhile: always provide a branch when pushing and multiple branches may match.

This has been remedied by the updated git push defaults. Just use push.default simple and a recent version of git.