Questions tagged [git-reflog]

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

git-reflog
Filter by
Sorted by
Tagged with
324 votes
8 answers
585k views

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 ...
timpone's user avatar
  • 19.6k
292 votes
13 answers
197k views

How do I remove the old history from a git repository?

I'm afraid I couldn't find anything quite like this particular scenario. I have a git repository with a lot of history: 500+ branches, 500+ tags, going back to mid-2007. It contains ~19,500 commits. ...
ebneter's user avatar
  • 21.2k
13 votes
2 answers
9k views

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 ...
Jeff Eisley's user avatar
93 votes
4 answers
46k views

Can I view the reflog of a remote (not remote ref)?

Is it possible to view the reflog of a remote? That is, I want to know what the output of git reflog is on another remote machine. Note that I am not asking for the reflog of remote-tracking branches (...
Alexander Bird's user avatar
240 votes
7 answers
119k views

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's user avatar
  • 15.1k
470 votes
8 answers
110k views

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 ...
Andrew Ferrier's user avatar
18 votes
1 answer
23k views

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 ...
codekandis's user avatar
14 votes
1 answer
1k views

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 ...
haziz's user avatar
  • 13.4k
8 votes
3 answers
5k views

How to git push the reflog?

Is there a way to push the reflog to a remote? This seems like it would be an incredibly useful thing to do, but I do not know of a way to do it. I'm envisioning something like git push --include-...
Alexander Bird's user avatar
7 votes
1 answer
4k views

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

I noticed in the documentation you can specify the parameter --grep-reflog --grep-reflog=<pattern> Limit the commits output to ones with reflog entries that match the specified ...
aug's user avatar
  • 11.5k
6 votes
1 answer
2k views

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 ...
ADTC's user avatar
  • 9,553
6 votes
2 answers
680 views

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 ...
LeGEC's user avatar
  • 49k
2 votes
0 answers
482 views

Scope of gc prune and git reflog expire, and related config

We are using throwaway integration branches which are pushed, and then later deleted and recreated. However the discarded branches are leaving dangling commits and trees which I can view with this ...
user2104419's user avatar
2 votes
1 answer
2k views

How to properly use `git reflog --since=...`?

I have a repository for which a regular git reflog --date=iso shows a lot of entries, for example see this fragment https://gist.github.com/FreddieChopin/0206c9ef530a056c624b065eed048c9d As you may ...
Freddie Chopin's user avatar
1 vote
0 answers
243 views

How can I use `git reflog format` while showing it as sorted by date?

I want list use git reflog format, and show it as sorted by date with (--date=relative) flag. git reflog --format='%C(auto)%h %<|(17)%gd %C(blue)%cr%C(reset) %gs' has following output: $ git ...
alper's user avatar
  • 3,218
0 votes
1 answer
1k views

git log --reflog vs git reflog [closed]

After playing around with rm etc etc, my git reflog no longer shows the past commits. However, git log --reflog is still able to show them. How does git log --reflog show dangling commits if it ...
Pacerier's user avatar
  • 88k
0 votes
0 answers
441 views

Why does git reflog show multiple batches of HEADs

I previously asked this but I closed it as it was a close duplicate of the same issue with git log. Now I have a similar question that why does git reflog show 'different lists of HEAD logs'? If I ...
mfaani's user avatar
  • 34.8k
0 votes
1 answer
390 views

What does the long empty space in git reflog signify? [duplicate]

After reading here as far as I have learned git reflog will show a list of all heads, basically it will keep a history after every checkout you do. Right? What I don't understand is why are there ...
mfaani's user avatar
  • 34.8k