Rebase changes from the master onto current branch
git fetch
Rebase
git rebase origin/master
Push
git push origin yourbranchname -f
Branches
Rename/move branch
git branch -m <oldname> <newname>
Tags
git tag -a v1.2 -m 'my annotation for v1.2'
Push the tag:
git push origin v1.2
Diverges
Solutions other than normal merge / mergetool workflowHard reset to the origin
git reset --hard origin/branchname
Fixing diverge by deleting branch (loosing you changes)
Checkout master:
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
Reverts
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
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
Diffs
show staged diff
git diff --cached
add only non white-space changes
git diff -w --no-color | git apply --cached --ignore-whitespace
Local User
Define a user for single repository:
git config user.email "your@mail.com"
git config user.name "Your Name"
No comments:
Post a Comment