0

I have a git repository (let's call it "CGR") cloned from a github fork (GK), that one forks an original github repo (GR). I do changes in CGR, and commit them on a branch B. Then, I pull the master branch from GR to CGR, and merge that master branch into B branch.

And after that operation, some files still remain unchanged. I can pull again, and git says "okay, your local branch is up to date with the GR branch".

I check a file in my local repository CGR (let's say, "pom.xml"), and there, I see that some modifications are missing.

So, there's the real question I have: does Git handle transactions when pulling and how does Git handle transactions? Because I suspect a network failure at the wrong time, leading to a corrupted local repository, which makes sense if Git has holes in its transaction mechanism or if it has no transaction at all.

Xenos
  • 3,351
  • 2
  • 27
  • 50
  • You're looking at this issue all sideways. The problem has nothing to do with database transactions or ACID properties (which Git achieves by a peculiar backdoor trick). It has to do with the fact that `git merge` works on a *purely textual, line-at-a-time basis,* with no knowledge of data structures embedded within XML or JSON or indeed any source code. For this reason, even if `git merge` *thinks* it has merged correctly, you must inspect the results. Doing `git pull` merely results in `git fetch` (which has atomic database-y properties) followed by `git merge`; it's the latter that fails. – torek Nov 17 '17 at 15:43
  • Does this answer your question? [Can a git repository be corrupted if a command modifying it crashes or is aborted?](https://stackoverflow.com/questions/8384101/can-a-git-repository-be-corrupted-if-a-command-modifying-it-crashes-or-is-aborte) – sleske May 15 '20 at 07:41

1 Answers1

0

There are reasonably good online resources that cover git's protocols and data structures. It's a lot of information. With that knowledge, understanding the mechanisms for ensuring consistency after a fetch or pull are pretty straightforward; without that knowledge, it would seem pretty incomprehensible in my opinion.

So if you really want to know, then you have some research to do; it would make no sense to try to reiterate it all here (and if I interpreted your question as a request for a documentation reference, then I suppose I would've down-voted it as off-topic instead of answering).

Failing that, all I can tell you is: no, your hypothesis does not make sense. You can choose whether to trust me on that - you wouldn't be the first to be dead sure that their incorrect observations are conclusive. But consider whether a gaping hole like you describe wouldn't be well-known by experience, and whether anyone would actually use git if that were the case.

Keeping in mind that git is a distributed source control system by design.

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52