I've noticed .git/log
while searching where git saves stash commits. Found that:
$ ls .git/logs/
HEAD refs
$ diff .git/refs/ .git/logs/refs/ | head -n3
Common subdirectories: .git/refs/heads and .git/logs/refs/heads
Common subdirectories: .git/refs/remotes and .git/logs/refs/remotes
diff .git/refs/stash .git/logs/refs/stash
Meaning stash
- is the only unique file under logs
. But it doesn't shed light on the rationale for this folder. So what is the purpose of .git/log
and why git duplicates references?
What does git log do? The git log command displays all of the commits in a repository's history. By default, the command displays each commit's: Secure Hash Algorithm (SHA)
To show all of the branches, add --all to your git log command. So basically, without --all you only see the commits that actually make up your current branch.
By default, git log includes merge commits in its output. But, if your team has an always-merge policy (that is, you merge upstream changes into topic branches instead of rebasing the topic branch onto the upstream branch), you'll have a lot of extraneous merge commits in your project history.
log is that the log is a public accounting of the repository's commit history while the reflog is a private, workspace-specific accounting of the repo's local commits. The Git log is part of the Git repository and is replicated after a push, fetch or pull. In contrast, the Git reflog is not part of the replicated repo.
logs Records of changes made to refs are stored in this directory. See git-update-ref1 for more information. This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/logs" will be used instead.
Reference: gitrepository-layout
They are the "reflogs" which record the history of where various references in your repository have pointed to in the past.
See git help reflog
and the documentation for -g, --walk-reflogs
in git help log
.
If you had run diff -r
you would see many more differences as the refs/
files all contain a single commit and logs/refs
contain a history file.
Note that looking that the refs/
directory is, in general, not a good way to look for refs in your repository. As well as being "loose", refs may also exist only in packed-refs
and not have a corresponding entry in the refs/
directory.
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