Questions tagged [git-reflog]

For issues relating to the git-reflog command to manage information recorded in reflogs.

git-reflog is a command to manage the information recorded in the reflogs.

Reference logs, or "reflogs", record when the tips of branches and other references were updated in the local repository.

Syntax:

git reflog <subcommand> <options>
65 questions
357
votes
7 answers

Is there a way to cause git-reflog to show a date alongside each entry?

The git-reflog command doesn't by default show a date alongside each entry, which strikes me as a strange oversight; I think this would be very helpful. Are there any command-line options, or other tweaks, which can be employed to cause it to show…
Andrew Ferrier
  • 13,902
  • 11
  • 40
  • 73
212
votes
8 answers

How can I move HEAD back to a previous location? (Detached head) & Undo commits

In Git, I was trying to do a squash commit by merging in another branch and then resetting HEAD to the previous place via: git reset origin/master But I need to step out of this. How can I move HEAD back to the previous location? I have the SHA-1…
timpone
  • 17,029
  • 31
  • 103
  • 200
184
votes
7 answers

What's the difference between git reflog and log?

The man page says that log shows the commit logs and reflog manages reflog information. What exactly is reflog information and what does it have that the log doesn't? The log seems far more detailed.
Noich
  • 11,783
  • 13
  • 59
  • 89
23
votes
2 answers

Git reflog a specific branch?

Can I reflog a specific branch? git reflog shows all history on the repo. But I want to check the history of one specific branch, say production. Is there a way to do that?
Asim K T
  • 12,493
  • 9
  • 67
  • 85
14
votes
1 answer

Keep Git Reflog Indefinitely?

I tend to be a bit paranoid about my data, including the ability to recover it. Git reflog data is pruned after 30 days. Is there a way of setting it so that the reflog data is maintained and kept indefinitely? Any major advantage or disadvantage…
haziz
  • 11,199
  • 14
  • 48
  • 69
12
votes
2 answers

Recover files that were added to the index but then removed by a git reset

I added some files to the index but then by mistake I deleted them with git reset --hard. How do I recover them? Here's what happened: I added all files using git add . I then committed When I checked the status, there were still files that…
Jeff Eisley
  • 183
  • 1
  • 2
  • 10
11
votes
2 answers

Is there a way to output the previous git branch name?

This answer tells how to checkout to the previous branch, and helpfully explains @{-1}: https://stackoverflow.com/a/7207542/3150057 The previous branch is important if I stashed some code before changing branch, and am now thinking about working on…
Henry Blyth
  • 1,538
  • 1
  • 12
  • 22
9
votes
1 answer

Where does git store its reflog?

I know that compressed version of reflog is stored in .git/packed-refs but where is actual reflog is located and how git restores history when one types git reflog ?
TOP KEK
  • 2,423
  • 5
  • 30
  • 57
7
votes
1 answer

GIT - Remove old reflog entries

After a lot of rebasing a repository to our latest needs our reflog is full of commits and orphan branches. We reached the final state of our reorganization. While there're branches and commits left with a lot of binary data the repository grew…
codekandis
  • 519
  • 1
  • 8
  • 19
6
votes
1 answer

What benefit is there to use --grep-reflog?

I noticed in the documentation you can specify the parameter --grep-reflog --grep-reflog= Limit the commits output to ones with reflog entries that match the specified pattern (regular expression). With more than one --grep-reflog,…
aug
  • 9,482
  • 6
  • 63
  • 84
6
votes
2 answers

Git: Deleted current branch and lost reflog

I ran into an unusual git issue earlier that I've since resolved, but I'm still curious as to why it happened. The problem occurred when I accidentally deleted the branch I was currently working on. Normally git wouldn't allow this, but due to…
user2221343
  • 584
  • 4
  • 16
5
votes
1 answer

What is the 2nd column in the git reflog?

I just did a simple git reflog and this is the first few lines I got: column1 Column2 Column3 2797a1d4 (HEAD -> master, upstream/master) HEAD@{0}: checkout: moving from master to master 2797a1d4 (HEAD…
Honey
  • 24,125
  • 14
  • 123
  • 212
5
votes
2 answers

Is there a reflog for the index?

I do not have a specific problem at hand, but I have encountered in the past some cases where I accidentally blew up my index, and wished I could go back the the previous state of a given file, which was indexed at some point. Some example cases are…
LeGEC
  • 29,595
  • 2
  • 37
  • 78
5
votes
1 answer

Push to origin after reflog expire and gc prune

I removed some unreachable and dangling commits in my local repo using git fsck --unreachable --dangling --no-reflogs git reflog expire --expire=now --all git gc --prune=now But I find the removed commits still available on the origin (GitHub, to…
ADTC
  • 7,367
  • 2
  • 57
  • 82
5
votes
1 answer

List squashed commits

After I do the interactive rebase: git rebase -i HEAD~20 I get a new commit, e.g. ea1234ea I know that the history is in the reflog, but how can I get a list of commits squashed in this commit including their identifiers (sha)? git show ea1234ea…
takeshin
  • 44,484
  • 28
  • 112
  • 160
1
2 3 4 5