Skip to content
cloLN edited this page May 3, 2012 · 8 revisions

##Candidate branches## If you get bored typing in the namefor the candidate branch (e.g., candidate-3.2.x) then you can create a symbiolic alias which can be used instead. E.g.,

git symbolic-ref refs/heads/next refs/heads/candidate-3.2.x

To find out the common commit point between two branches use.

git merge-base branch1 branch2

E.g., to check out a new branch based on a common commit point, using the symbolic alias and merge-base executed inline you can do

git branch newbranch `git merge-base master next`

##Revision syntax## Quite a useful link for understanding what the different formats for the references to commit versions (e.g., HEAD^2~5^^), see Specifying revisions

##Comparison## If you use beyond compare then take a look at https://github.com/thenigan/git-diffall - a very useful varient of difftool which displays all the differences at once in a directory comparison.

To find out what changes from upstream\master are available to merge into your master

git fetch upstream
git log master..remotes/upstream/master

##Command Aliases## Display the last commit.

log1=log -n 1  

Display a list of all changes since the master

logm=log master..

Display a tree of the commits.

tree=log --graph --oneline

What branch am I currently on?

whoami="!f1() { git branch --merged HEAD --color=never | grep '*' | sed 's/* //'; }; f1;"

What is the common commit between this branch and master?

mcommon="!f1() { git merge-base `git whoami` master; }; f1;"

Use the diffall tool to generate all difference between this branch, and its common commit with master.

bc="!f1() { git diffall `git mcommon`; }; f1;"

And if you really want a graphviz dependency view of your commits....

graphviz = "!f1() { git log --pretty='format:  %h -> { %p }' \"$@\" | sed 's/[0-9a-f][0-9a-f]*/\"&\"/g' ; }; f2() { git log --pretty='format:  \"%h\" [ label=\"%s\" ];' \"$@\"; }; echo 'digraph git {' ; f1; f2; echo '}'; "

##Merging code from someone else's branch into your working branch## From time to time, it might be necessary to pull someone else's branch into your own. Here are the commands for that: git pull https://github.com/hpcc-systems/HPCC-Platform.git git checkout -b NameOfYourOwnBranch NameOfBranchYouWantToBaseItOn git pull https://github.com/DeveloperName/HPCC-Platform.git TheirBranch

##Generating Pretty ChangeLogs## git log --since=2012-01-01 --until=2012-01-31 --pretty=format:'%h|%an|%ai|%s|'