Skip to content

Instantly share code, notes, and snippets.

@marcoow
Forked from next2you/change default branch name.sh
Created October 12, 2010 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcoow/622464 to your computer and use it in GitHub Desktop.
Save marcoow/622464 to your computer and use it in GitHub Desktop.
# which branch does contain the given commit
git branch --contains d590f2
# Given some SHAs from commits, create a hotfix for this
# 0. Make sure you are working on a clean working copy
git status
# 1. Find the commits
# 2. Determine which branch they are on
git branch --contains COMMIT_SHA
# 3. Create branch from production (XXXX == ticket number)
git checkout production
git checkout -b hotfix/XXXX
# 4. Cherry-pick the changes
git cherry-pick COMMIT_SHA
# 5. if necessary resolve merge conflices
# 6. push hotfix
git push origin hotfix/XXXX
# branch to delete == hotfix/2534
# 0. make sure this is fully merged
git checkout develop
git pull
git merge hotfix/2534
# => should be already up to date, maybe also do it in production/corporate-production
# 1. delete local branch
git branch -d hotfix/2534
# 2. delete remote local branch (copy of remote in local repository), assuming remote is named origin
git branch -r -d origin/hotfix/2534
# 3. delete branch on remote
git push origin :hotfix/2534
find /var/git/repositories -name '*.git' | xargs -I % sh -c "cd %; sudo -u git git gc"
# all missing commits from production but in list
# needs to be reviewed if this is really doing what is advertised
git show-branch --topic --sha1 production list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment