4

I'm currently making commits and using branches in my remote Git repo. But, whenever I use:

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

It just shows my commit history in a single line - no branches, despite branches being named 'origin/API', 'origin/dev' and 'origin/master'.

A screenshot of my terminal output

If you have a look at Showing Git branch structure (where I got the command from) the screenshot shows 'branches' and 'merges'

Can you guys help me? I wish to view my repo in a tree fashion (helps me visualise better) rather than a beanstalk...

Community
  • 1
  • 1
thisispiers
  • 109
  • 9
  • What do you see if you also pass `--all`? –  Jul 15 '13 at 15:58
  • Also, whatever your current branch is in the picture, it appears that it doesn't have any merge commits (not necessarily a bad thing). –  Jul 15 '13 at 15:59
  • I tried that @Cupcake, but no luck. Also, the branches are not quite at the stage where I should merge them yet. – thisispiers Jul 15 '13 at 16:08
  • 1
    what version of git do you use on what system? it "works for me". – mnagel Jul 15 '13 at 16:16
  • Tell you what, if you add the output of `git log --oneline --graph --all --decorate` to your question, maybe we can figure it out. You can remove sensitive information from the output if you need to. –  Jul 15 '13 at 16:16
  • Also, just a note, in your picture above, `dev` is a branch of `master`, and `API` is a branch of `dev`. They're in a straight line because there are no merge commits. Did you just start this project, and is that how you organized your branches? Did you make a dev branch off of master, and an API branch off of dev? That would actually explain why you're seeing a straight line. –  Jul 15 '13 at 16:20
  • Just a note for future editors, the title of this question should be edited so that it's easier for other people to understand what the actual problem was, and make it more easily searchable. –  Jul 18 '13 at 06:19

4 Answers4

4

Try this one to view a graph of your repo over time.

git log --oneline --graph --all --decorate

Note that the decorate will show you where the heads of the various merged in branches are. And oneline gets it all on one line so that it is easy to navigate.

usumoio
  • 3,500
  • 6
  • 31
  • 57
  • Thanks for the suggestion, unfortunately, it didn't change anything...still showing a stream of commits without branching :( – thisispiers Jul 15 '13 at 16:09
  • I think the "issue" might be that the ancestor branches haven't diverged from their children yet, so the children appear on the same line as the ancestors, which isn't an error. –  Jul 15 '13 at 16:43
2

From the original poster:

If you have a look at Showing Git branch structure (where I got the command from) the screenshot shows 'branches' and 'merges'

screenshot of other log output with merge commits

If you want to see divergent branches in your log output, you have to have merge commits. You haven't actually done any non-fast-forward merges yet (which will produce merge commits), so what you're seeing is indeed all of your branches, with master an upstream parent of dev, and dev an upstream parent of API.

original poster's log output

You'll start seeing merge commits if you do a non-fast-forward merge of API into the dev branch, for example:

# From the dev branch
$ git merge --no-ff API

$ git log --oneline --graph --decorate
* 419eadf (HEAD, dev, API)
|\ 
| * 1b6ebed where API used to be
|/ 
* 51464fc where dev used to be
|
* asdfhsdf (master)
Community
  • 1
  • 1
1

You can try the command given below. It worked for me.

git log --oneline --graph --all --decorate

Akhil
  • 1,073
  • 1
  • 9
  • 28
Mayavi
  • 149
  • 6
0

Use gitk, a graphical history viewer that comes bundled with git.

You can run it from your command line, it accepts many options, most of which are passed through to git log.
$ gitk [git log options]

Source

Salim Mahboubi
  • 561
  • 7
  • 25