Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does git record history of branch heads?

Tags:

git

branch

refs

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

Does Git record the history of the state of these pointers?

I see at least two reasons for this:

  • To see the state of the repo two days ago, including where the branch heads pointed.
  • To make sure no history is lost because someone moved a branch head in a way that some commits become unreachable.

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

So again, in Git are the contents of .git/refs/ version controlled, or is there a way to make them so?

(I'm trying to decide on Mercurial or Git for a team, and I want to make sure all changes to the shared repo, including the refs, are recorded. I don't care what developers do to their private repos.)

Thank you.

like image 983
Jake Lundy Avatar asked May 07 '11 02:05

Jake Lundy


People also ask

Does git save history?

Git stores the complete history of your files for a project in a special directory (a.k.a. a folder) called a repository, or repo.

How do I find my GitHub branch history?

Click History. On the History tab, click the commit you'd like to review. If there are multiple files in the commit, click on an individual file to see the changes made to that file in that commit.

How do I see my git log history?

`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.

How get commit history of branch?

On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.


1 Answers

They're not versioned, but the reflog feature keeps a local history that you can use to undo mistakes. However, if someone "rewinds" a branch head to discard some commits from the end, it'll become immediately obvious when another developer tries to update their checkout of that branch, because Git will refuse to make that change locally unless --force is used. You can easily just push the commits back to the shared repository at that point.

like image 82
Wyzard Avatar answered Sep 30 '22 19:09

Wyzard