Reputation: 5905
I have a bunch of work that got "lost" in our git repository. i.e. I committed a number of files, and someone did a merge somewhere, that "lost" all my changes. I'm struggling to determine how/where this happened. When I look at the log of changes to my file using this command from this question:
gitk --all -- version.txt
I get the following screenshot:
This file is managed by our build system, and it should contain the string,
1.0.94.0
AT least, based on what I'm seeing in the above screenshot. But in fact, it actually contains the string:
1.0.92.0
In digging through the repository, someone performed a merge, and the merge overwrote version.txt with the contents 1.0.92.0. But that merge did not appear in my gitk output. Is there a way to run gitk (or git) to show me all the merges and commits that modified my file?
Upvotes: 1
Views: 503
Reputation: 487755
It's worth trying adding --full-history
to your gitk
command. gitk
runs git log
(and sometimes git rev-list
) with these gitk-controlled options:
# Start off a git log process and arrange to read its output
proc start_rev_list {view} {
global startmsecs commitidx viewcomplete curview
[mass snippage]
if {$vcanopt($view)} {
set revs [parseviewrevs $view $vrevs($view)]
if {$revs eq {}} {
return 0
}
set args [concat $vflags($view) $revs]
} else {
set args $vorigargs($view)
}
if {[catch {
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
--parents --boundary $args "--" $files] r]
} err]} {
error_popup "[mc "Error executing git log:"] $err"
return 0
}
By default, looking at specific files, i.e., when $files
is not empty, enables what git log
calls History Simplification. I find the documentation here to be somewhat confusing, but in short, without --full-history
, Git will prune some merge parents when the parent contains the file in its current format.
Note that --full-history
is not included in the options, but one of them is $args
, which is at least sometimes set based on $vflags($view)
, and $vflags
may include --full-history
.
If you use git log
directly, consider adding both --full-history
and -m
. By default, git log
does not look at the diffs of merges. The -m
flag causes it to split each merge into one commit-pair per parent (parent-n vs child), and then look at each of those diffs.
I'm not sure if or how this affects gitk
since gitk
does extra work with git rev-list
, but it's possible that adding -m
to gitk
's options is required as well.
Upvotes: 1