I am currently taking my first steps using git. Can you please tell me if the following scenario is possible?
Let's imagine a branch for an old version of a software that is needed only very rarely. Let's say, it points to commit 6c0508c3e. Now, some developer deletes the branch. First issue: changes to branches are not tracked. So I cannot detect who did it.
Question 1: Is this correct? Can I really not detect who deleted the branch?
But at least the commit is still there (only not reachable anymore). So the code can still be retrieved using the commit's hash (6c0508c3e). But after some time, the git garbage collection detects that the commit is unreachable and will actually delete the commit 6c0508c3e.
Then, a few years later, some other developer wants to patch the old version. But the branch is gone. And there is no way to retrieve the code, since the GC deleted it.
Question 2: Is this possible as well?
CodePudding user response:
Remember that Git is about distributed version control.
You control your repository. I have my own repository; you don't control this one. You literally can't.
If you don't want to delete names, so that you don't lose commit hash IDs, just don't delete the names and you won't lose the commit hash IDs. They're your names. They're keeping track of commits for you, according to your whims. They're not my names—I can't touch your repository—so I can't affect your copies in your repository.
That's basically all there is to it. Keep control over the parts you want control over. Hand off control once you don't care any more.
CodePudding user response:
Judging from the statements I got, the answer is "yes" to both questions.
Normally, source control systems give you two very basic promises: "Once your code reaches the repository, it will always be possible to restore this exact state. And you will always be able to track who changed this state."
Git violates these promises:
- You cannot reliably restore a certain point in time.
- A state can even be lost forever.
- You cannot even reliably track down who did it.
And the accepted answer seems to be: "Just be careful what you do."