sudo service gitlab stop
#Set the working directory
cd /home/gitlab/gitlab/
# Get latest code
sudo -u gitlab -H git fetch
sudo -u gitlab -H git checkout 4-2-stable
# Install libs
sudo -u gitlab -H bundle install --without development test postgres --deployment
# update db
sudo -u gitlab -H bundle exec rake db:migrate RAILS_ENV=production
sudo -u gitlab -H bundle exec rake gitlab:check RAILS_ENV=production
sudo service gitlab start