1. Git¶
1.1. Rebase a branch on master¶
# Check that your local master is up-to-date
git checkout master & git pull
# Go on you otherBranch
git checkout otherBranch
# Rebasing
git rebase master
# Push
git push --force-with-lease
1.2. Merging a Branch¶
# Back on master
git checkout master
# Merging
git merge otherBranch
# Push
git push
1.3. Delete a Branch¶
# delete branch locally
git branch -d localBranchName
# delete branch remotely
git push origin -d remoteBranchName
1.4. See all branches on remote and local¶
git branch -avv
1.5. Revert a commit¶
git revert HEAD~1..HEAD
or
git reset --hard HEAD^
Revert several commits
git revert HEAD~3..HEAD
1.6. Resolving merge conflicts automatically¶
In cases when you prefer the work of other developers rather than yours.
git pull -X theirs
In cases when you prefer your work.
git pull -X ours