Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of .git/log

Tags:

git

git-stash

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?

like image 242
Ilia Barahovsky Avatar asked Jul 10 '16 11:07

Ilia Barahovsky


People also ask

What is git log is used for?

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)

What is git log -- all?

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.

What is the output of git log?

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.

What is the difference between git log and git log?

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.


2 Answers

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

like image 179
ElpieKay Avatar answered Oct 11 '22 22:10

ElpieKay


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.

like image 39
CB Bailey Avatar answered Oct 11 '22 21:10

CB Bailey