I'm very new to git, I want to know how to track branch history?
For example:
echo "update README in branch master" >> README.md
git commit -a -m"commit in branch master"
git checkout -b b1
echo "update README in branch b1" >> README.md
git commit -a -m"commit in branch b1"
git checkout master
git merge b1
git push
then someone clone this repo, how to show branch history?
git log --graph
* commit 4162ecc962aa020ec6294312e4f8eed63ca152d1
| Author: test1 <[email protected]>
| Date: Fri Feb 15 14:37:43 2013 +0900
|
| commit in branch b1
|
* commit 08e80fc644fa7ebb374a601e16533a8fc3578f88
| Author: test1 <[email protected]>
| Date: Fri Feb 15 14:37:04 2013 +0900
|
| commit in branch master
|
* commit 9d9649cdb409654616798d8feeb516738997e2e0
Author: test1 <[email protected]>
Date: Thu Feb 14 21:33:46 2013 -0800
Initial commit
I also see some this kind of log:
* commit 2f49d77afe0708037eab1de3d216484d01f1c190
| Author: ericz <[email protected]>
| Date: Wed Feb 13 11:45:49 2013 -0800
|
| readme update
|
* commit 996214b87cce3473297ed0997ca567497271e05a
|\ Merge: a239b70 5269cd4
| | Author: ericz <[email protected]>
| | Date: Wed Feb 13 11:45:23 2013 -0800
| |
| | Merge branch 'master' of github.com:peers/peerjs
| |
| * commit 5269cd455f1522e88ab5a15228effe11665e6a89
| | Author: Eric Zhang <[email protected]>
| | Date: Wed Feb 13 09:47:05 2013 -0800
| |
| | Update README.md
| |
* | commit a239b706f294c469a5c6542ce7e6f5e60417445a
| | Author: ericz <[email protected]>
| | Date: Wed Feb 13 11:45:09 2013 -0800
| |
| | new exmales
| |
* | commit 0ce560d093637b3a17c7b5f1ab1de3f9c00bb888
|/ Author: ericz <[email protected]>
| Date: Wed Feb 13 11:02:33 2013 -0800
|
| simple chat example
how this happen?
and how to draw graph like this:
D---E-------F
/ \ \
B---C---G---H---I---J
/ \
A-------K---------------L--M
You're on the right track. Try using:
git log --graph --all --oneline
Here's an example:
* e96e246 H
| * c12759a G
|/
* 547058e F
|\
| * b81eb87 E
* | 26a34db D
| | * 47a536f C
| | * b8fa965 B
| |/
|/|
* | cd14ec4 A
I personally use an alais in .gitconfig,
[alias]
graph = log --graph --all --date=short --pretty=format':%C(yellow)%h%Cblue%d%Creset %s %Cgreen %aN, %ad%Creset'
Which gives a similar output, but with slightly more awesomeness (branches, dates, authors):
* e96e246 (HEAD, master, origin/master) H. Developer A, 2012-12-13
| * c12759a (branch_2) G. Developer B, 2012-12-13
|/
* 547058e F. Developer C, 2012-12-11
|\
| * b81eb87 E. Developer A, 2012-11-28
* | 26a34db D. Developer C, 2012-12-11
| | * 47a536f (branch_1) C. Developer B, 2012-10-10
| | * b8fa965 B. Developer B, 2012-10-11
| |/
|/|
* | cd14ec4 A. Developer B, 2012-10-10
If you have the ability to use a GUI with git, gitk is usually highly recommended for this kind of thing. Here's an intro.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With