Skip to content

Instantly share code, notes, and snippets.

@next2you
Created September 2, 2010 08:59
Show Gist options
  • Save next2you/562073 to your computer and use it in GitHub Desktop.
Save next2you/562073 to your computer and use it in GitHub Desktop.
GIT commands
# Change the default branch (which is used after git clone your-repo) to branch develop
# Be sure to run this on the remote repository, this cannot be pushed (as far as I know)
git symbolic-ref HEAD refs/heads/develop
# don't forget to delete master afterwards
git branch -d master
# or if you want to do it remote
git push origin :master
# 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"
#!/bin/bash
pushd . # save current place in filesystem
until [ -d .git ] || $(pwd) = "/" ; do # look for project root
cd ..
done
if [ -d .git ] ; then # if we found it...
git submodule update
fi
popd # reset to original place in filesystem
# 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
# all missing commits in production but not in list (variant 2)
git log production..list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment