Rebase changes from the master onto current branch
git rebase origin/master
git push origin yourbranchname -f
git branch -m <oldname> <newname>
git tag -a v1.2 -m 'my annotation for v1.2'
Push the tag:
git push origin v1.2
DivergesSolutions other than normal merge / mergetool workflow
Hard reset to the origin
git reset --hard origin/branchname
Fixing diverge by deleting branch (loosing you changes)
git checkout master
Delete diverged branch (dispose all local changes):
git branch -D branchname
Checkout branch back:
git checkout branchname
Fixing diverge by hard reset to some particular commit (loosing you changes)
git reset --hard g00dcmid
assume that you're currently at diverged branch and g00dcmid is a last commit before diverge
please be aware that it will revert all files in the INDEX and in the WORKDIR
revert a commit
git revert c0mm1tid
notice, that this will revert this particular commit, not revert to this commit
delete local commits
git reset --hard <commit or branch>
search in commit names
git log --all --grep='some stuff'
--all means - search in all branches
search in patches / diffs (Pickaxe)
git log -S "text to find"
it is also possible to add -p option to list actual diffs
show staged diff
git diff --cached
add only non white-space changes
git diff -w --no-color | git apply --cached --ignore-whitespace
Define a user for single repository:
git config user.email "firstname.lastname@example.org"
git config user.name "Your Name"