По соображениям производительности вывод в файлы буферизуется. Таким образом, данные могут фактически не записываться в файл до тех пор, пока вы не скажете «написать буфер на диск сейчас». Это традиционно выполняется с помощью flush()
. truncate()
, очевидно, сбрасывается перед усечением.
git log --graph
или gitk
. (Оба также принимают - все
, при этом будут отображаться все ветви вместо только текущей.)
Изменить:
Для имен веток и компактного представления попробуйте: git log --graph --decorate --oneline
I usually use
git log --graph --full-history --all --pretty=format:"%h%x09%d%x20%s"
With colors (if your shell is Bash):
git log --graph --full-history --all --color \
--pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"
This will print text-based representation like this:
* 040cc7c (HEAD, master) Mannual is NOT built by default
* a29ceb7 Removed offensive binary file that was compiled on my machine and was hence incompatible with other machines.
| * 901c7dd (cvc3) cvc3 now configured before building
| * d9e8b5e More sane Yices SMT solver caller
| | * 5b98a10 (nullvars) All uninitialized variables get zero inits
| |/
| * 1cad874 CFLAGS for cvc3 to work succesfully
| * 1579581 Merge branch 'llvm-inv' into cvc3
| |\
| | * a9a246b nostaticalias option
| | * 73b91cc Comment about aliases.
| | * 001b20a Prints number of iteration and node.
| |/
|/|
| * 39d2638 Included header files to cvc3 sources
| * 266023b Added cvc3 to blast infrastructure.
| * ac9eb10 Initial sources of cvc3-1.5
|/
* d642f88 Option -aliasstat, by default stats are suppressed
(You could just use git log --format=oneline
, but it will tie commit messages to numbers, which looks less pretty IMHO).
To make a shortcut for this command, you may want to edit your ~/.gitconfig
file:
[alias]
gr = log --graph --full-history --all --color --pretty=tformat:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s%x20%x1b[33m(%an)%x1b[0m"
However, as Sodel the Vociferous notes in the comments, such long formatting command is hard to memorize. Usually, it's not a problem as you may put it into the ~/.gitconfig
file. However, if you sometimes have to log in to a remote machine where you can't modify the config file, you could use a more simple but faster to type version:
git log --graph --oneline
I like, with git log
, to do:
git log --graph --oneline --branches
(also with --all, for viewing remote branches as well)
Works with recent Git releases: introduced since 1.6.3 (Thu, 7 May 2009)
"
--pretty=
" option to the log family of commands can now be spelled as "--format=
".
Кроме того,- format =% formatstring
является сокращением для- pretty = tformat:% formatstring
."
- oneline
" является синонимом для «- pretty = oneline --abbrev-commit
».
PS D:\git\tests\finalRepo> git log --graph --oneline --branches --all
* 4919b68 a second bug10 fix
* 3469e13 a first bug10 fix
* dbcc7aa a first legacy evolution
| * 55aac85 another main evol
| | * 47e6ee1 a second bug10 fix
| | * 8183707 a first bug10 fix
| |/
| * e727105 a second evol for 2.0
| * 473d44e a main evol
|/
* b68c1f5 first evol, for making 1.0
Вы также можете ограничить диапазон отображения журнала (количество коммитов):
PS D:\git\tests\finalRepo> git log --graph --oneline --branches --all -5
* 4919b68 a second bug10 fix
* 3469e13 a first bug10 fix
* dbcc7aa a first legacy evolution
| * 55aac85 another main evol
| | * 47e6ee1 a second bug10 fix
(показывать только последние 5 коммитов)
Что мне не нравится в текущем выбранном решении:
git log --graph
В нем отображается слишком много информации (когда я хочу только просмотреть краткую сводку):
PS D:\git\tests\finalRepo> git log --graph
* commit 4919b681db93df82ead7ba6190eca6a49a9d82e7
| Author: VonC <vonc@laposte.net>
| Date: Sat Nov 14 13:42:20 2009 +0100
|
| a second bug10 fix
|
* commit 3469e13f8d0fadeac5fcb6f388aca69497fd08a9
| Author: VonC <vonc@laposte.net>
| Date: Sat Nov 14 13:41:50 2009 +0100
|
| a first bug10 fix
|
gitk
отлично, но вынуждает меня покинуть сеанс оболочки для другого окна, тогда как быстрого отображения последних n коммитов часто бывает достаточно.
Gitx также является фантастическим инструментом визуализации, если вы используете OS X.