06 November 2016

Tips

check if branchA has been merged into branch master:

git log master branchA

Suggested format of commit message:

It's suggested by GIT manual to have a one-line summary followed by a blank line, then followed by multiple lines of details

revert a commit/merge

To revert a particular commit, i.e. applying a reverse-patch

git revert <commit>

But to revert a merge, we need to specify which parent of the commit we want to keep

git revert <commit> -m 1

this will keep parent 1 as the mainline.

To find out which parent is 1 or 2, we can use

git log --merges

make a new local branch to track a remote branch

#+beginsrc sh git fetch <remote> <rbranch>:<lbranch> git checkout <lbranch> #+endsrc sh

make a new branch for merging with two diverged branches

find the most recent common ancestor of two brances

git merge-base branchA branchB

or for the full commit info

git log -1 $(git merge-base branchA branchB)

then make a feature branch from the common ancestor commit

git branch branchname <sha1-of-commit>


blog comments powered by Disqus