Skip to contentSkip to conversation

why is git destructive by default? (i suggest it not be!)

DISCUSSION Teemu Likonen 1 participant 2 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

David Jeske wrote (2008-06-24 01:47 -0000):

Quoted 3 lines

As a new user, I'm finding git difficult to trust, because there are operations which are destructive by default and capable of inadvertently throwing hours or days of work into the bit bucket.

I'm also quite new and I actually feel safe using git, and it's because of reflog. No matter what I do (except manual reflog expire) I can see where I was before with command

  git log --walk-reflogs

and get everything back. I have needed it a couple of times. So the safety net is there, one just has to learn to trust it. :-)

Git is much safer than the standard Unix tools like rm, mv and cp.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

David Jeske wrote (2008-06-23 22:01 -0700):

Quoted 7 lines
Quoted 4 lines · Teemu Likonen

I'm also quite new and I actually feel safe using git, and it's because of reflog. No matter what I do (except manual reflog expire) I can see where I was before with command

Quoted 5 lines
Quoted 1 line

git log --walk-reflogs

Perhaps I'm misunderstanding how to read it, but how do you tell where a branch was from the reflog if you inadvertantly moved it?

Perhaps I'm misunderstanding what you mean but I try to explain. In git branches are nothing but named pointers to certain commit. If you "move a branch" you actually rename the pointer, nothing more. With command

  git log --walk-reflogs --all

you can see everything in your reflog. When branches are moved (i.e., renamed) in "git log --walk-reflogs" output it shows like this:

commit 269f10bca2273c1cf77831d5e23c6e0361217697
Reflog: refs/heads/master@{2008-06-24 08:15:56 +0300} (Teemu Likonen <[email protected]>) Reflog message: Branch: renamed refs/heads/master to refs/heads/testbranch
Author: Teemu Likonen <[email protected]>
Date: 2008-03-25 19:10:40 +0200

[commit message]

See the "Reflog message" field above. It tells what happened. The "Reflog" field tells when it happened. If I later remove this "testbranch" I can browse the reflog and create this branch (i.e. a pointer) again with command "git branch testbranch 269f10bca". The 269f10bca comes from the commit ID of the above log item.