tags:

views:

60

answers:

2

I use git log, but I find it can only list logs under current branches, but I want to list all the loges for all the branches and sort by modified date, is that possible ? How to do that ?Thanks in advance !

+1  A: 

git log --all

Matt Curtis
tested, but only display the log of master branch
MemoryLeak
It certainly can't list the logs of a different branch on a remote machine, without first merging them into the current branch. What other references would you want it list? A subset could be shown by the `git branch -a` command.
Arafangion
but in gitk gui, I can see all the logs include all the branches!How can I get that with command line ?
MemoryLeak
That behavior should be provided by the --all argument, as mentioned. See the git documentation for that command. (Is it possible that the commits you expect to see are lost in the noise? Also keep in mind that gitk also looks at the index).
Arafangion
are you kidding me ? I tried your command again,but still not work. miss the logs in the branch I just modified.
MemoryLeak
What kind of branches are we talking about? The branches you are interested in are evidently not in .git/refs. In that case, see VonC's answer. Keep in mind that a "branch" is really a named head. Any commit could be a branch, depending on how you choose to define it.
Arafangion
actually i don't name the branch, i just use checkout to revert to previous version as a branch
MemoryLeak
If you're just checking out a commit, there is no branch. Git will warn you of this when you check out.
Matt Curtis
but in the git gui, it draw a branch from master, so I think it's a branch, is there any mean I can update the master to previous version? just like svn update?(but not create a new branch)
MemoryLeak
@MemoryLeak: To pick up a detached HEAD you need to include HEAD with `--all`: `git log <other-options> --all HEAD`
Chris Johnsen
fatal: ambiguous argument 'HEAD': both revision and filenameUse '--' to separate filenames from revisions ---- I got this error message
MemoryLeak
+1  A: 

You can check this question to see if this begin to address your log level:

git log --graph --abbrev-commit --pretty=decorate --branches

it should list all branches including remotes ones (if fetched)

--branches[=pattern]

Pretend as if all the refs in refs/heads are listed on the command line as <commit>.
If pattern is given, limit branches to ones matching given shell glob.
If pattern lacks ?, , or [, / at the end is implied.


You can try this commandline-fu, with git branch or git branch -a:
(git branch -a is certainly what you need of you want to see the same branches than gitk)

for k in `git branch -a|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset%cn: %s" $k|head -n 1`\\t$k;done|sort -r

or:

for k in `git branch -a|sed s/^..//`;do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset%cn: %s" "$k"`\\t"$k";done|sort

(you can complete the format to show any data -- author, commit message, ... -- you need)

Show git branches by date - useful for showing active branches Print out list of all branches with last commit date to the branch, including relative time since commit and color coding.


Note: As Jakub Narębski aptly comments:

Don't use git branch output for scripting!!! Use git for-each-ref or git show-ref plumbing (low-level commands meant for scripting)

git branch is a porcelain command precisely because it meant for user, and not for scripting.

As Eric Raymond puts it, It fits the well-established git design philosophy of separating content manipulation (plumbing) from presentation (porcelain).

VonC
Don't use `git branch` output for scripting!!! Use `git for-each-ref` or `git show-ref` plumbing (low-level commands meant for scripting).
Jakub Narębski