by dgan · 3y ago · 0 comments
ls -l .git/refs/remotes/origin/master
origin/master is just a file on your system, you can see when it has been changed. It doesn't magically get updated. Do `git fetch origin` and if there are any changes, you'll see the timestamp change, and the contents:
cat .git/refs/remotes/origin/master
The basics of git are so simple, you can implement the core data structures and some operations in a day. It is really worth it to get to know these.
Somehow git has managed to create a very complex user interface on top of quite a simple core.
Is it though?
Consider a bank telling a store I am buying things at "This person has has €450 in their bank account", when at that moment I have €310. The store would be rightfully pissed at the bank for effectively lying when it is made clear later on that the transaction could not be completed and the bank answers "well, the person had €450 a few days prior to you asking us".
Without an explicit temporal information it is explicitly now.
Without an explicit status on sync status it is implicitly saying sync is up-to-date.
It's a lie of omission.
Yes, yes it is.
origin/master is not saying that the remote has/hasn't changed. It's comparing your local copy of origin/master, not giving you the status about if remote has/hasn't changed. You need to explicitly ask if remote/origin/master has changed or not if you want to know.
Which in your analogy would be like if the store forgot to actually ask the bank if the customer had the money or not, and instead relying on whatever information they have "cached" in the store. Instead, the store has to first ask the bank (remote) if there is any changes.
I do agree that it could be worded better to actually help the user understand, as it seems to be a common misconception.
Sidenote: I'd be driven to absolute insanity if `git status` started doing remote requests to check the remote origin/master status each time I invoked it.
Git hurts my brain.
but it's not?
if you have an old bank receipt that says you have $450 in your account, but you actually have $310, you need to "get" a new receipt that has the newest value.
you do that by issuing git fetch origin. then you can git merge origin/master to make everything up-to-date.
A problem it has is there is now a generation of developers who don't know why we don't use centralised VC any more.
git has a better experience than cvs or svn if you're far away from the VCS server, but that was solvable by having dev machines near the VCS server. I've gotten used to the git workflow, but it still doesn't strike me as uniformly better, other than if you're using git, you don't have to deal with everybody always ask why aren't you using git.
That's pretty close to how holds / unresolved transactions work.
The confusion lies in that origin refers to different things depending on if it's `origin master` or `origin/master`. Eg `git pull origin master` does the thing we expect
Git is not well designed for human beings.
It's not a biggy, it's just one of the little toe-stubs and paper cuts you get over pretty quickly.
Unless it's a packed ref (https://git-scm.com/docs/git-pack-refs), in which case it's just a line in the packed-refs file.
Further it does nothing - it tells you nothing about the remote. It could be 1 second or 100 years and you would still need to fetch to determine if anything is different. Then what is the information for?
(very large sigh)
Can't wait to retire in three years and wash my hands of this broken trash.
I hope you "git pull -r" every time. Merges are almost always unwanted.