felixabele
6/12/2013 - 10:22 AM

GIT

GIT

# Delete local branches no longer on remote
git remote prune origin

# Revert to a commit
git reset --hard 0d1d7fc32

# Replace a Branch with another
git checkout master
git reset --hard experiment

# migrate commits
git checkout newbranch
git cherry-pick 612ecb3
git cherry-pick 453ac3d
git cherry-pick 9aa1233

# delete remote branch
git push origin --delete <branchName>

# search for a string in code history
git log -Sallow_billpay

# delete all stashes
git stash clear

# clear History
git branch -D api2

# clear local branches which where deleted on remote
git remote update origin --prune

# delete branch
git checkout --orphan temp $1
git commit --allow-empty -m "Truncate history"
git rebase --onto temp $1 master
git branch -D temp
git gc

# add changes to an old commit
git add <my fixed files>
git commit --fixup=OLDCOMMIT
git rebase --interactive --autosquash OLDCOMMIT^

# rename branch
git branch -m <newname>