Does Git write branch header history?

Git headers and branch tags are pointers to commits, and these pointers can move either implicitly (after a commit ) or explicitly (after branch -m ).

Does Git record the status history of these pointers?

I see at least two reasons for this:

  • To see the status of the repo two days ago, including where the branch headers were indicated.
  • In order not to lose the story, because someone has moved the branch in such a way that some commits become inaccessible.

Note that the above is possible in Mercurial, because it stores the branch name in each commit.

So, does Git contain the contents of .git / refs / version or is there a way to make them like that?

(I'm trying to make a decision on Mercurial or Git for the team, and I want all changes in the general repo, including refs, to be recorded. I don't care what the developers do with their private repositories.)

Thanks.

+8
git branch
source share
3 answers

They are not versioned, but the reflog function stores a local history that you can use to troubleshoot errors. However, if someone β€œrewinds” a branch of a branch to undo some commits from the end, it will become apparent when another developer tries to update their check for this branch because Git will refuse to make this change locally if --force used. You can simply simply transfer the commits back to the shared repository at this point.

+7
source share

There are extensions for corporate Git servers, such as Gerrit, that will have a history version of your branch. If the branch is deleted or updated in a non-transitive way (push -f), it will return the previous version under a special ref so that they can be restored if necessary, and will not be cut off by garbage collection. Gerrit administrators can still delete selected commits, if necessary for legal reasons.

+1
source share

There are two ways:

 git reflog 

and

 git log -g 

Equivalent to the first case:

 git log --oneline -g 
0
source share

All Articles