Inside the Hidden Git Folder - Computerphile

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ก.ย. 2024
  • Git doesn't actually perform magic, but it's pretty neat. Dr Max Wilson takes us through the various elements that make Git such a useful tool.
    NB at some point in this video I inserted some b-roll recorded via my raspberry pi and yes I used sudo where it wasn't required so sue(do) me! Sean
    / computerphile
    / computer_phile
    This video was filmed and edited by Sean Riley.
    Computer Science at the University of Nottingham: bit.ly/nottsco...
    Computerphile is a sister project to Brady Haran's Numberphile. More at www.bradyharan.com

ความคิดเห็น • 314

  • @Halinn
    @Halinn 2 ปีที่แล้ว +684

    So it's entirely magic, got it.

    • @Luiz997488
      @Luiz997488 2 ปีที่แล้ว

      exactly

    • @AndersJackson
      @AndersJackson 2 ปีที่แล้ว +3

      Technical problems advanced enough looks like magic. Until you understand them.

    • @bakedbeings
      @bakedbeings 2 ปีที่แล้ว +3

      Torvalds: it's Finnish for *#!@ing magic.

    • @mantaz40
      @mantaz40 2 ปีที่แล้ว +2

      Theres many things magical this channel presents just few can fully grasp but this time its pure and simple to understand. Git is awesome

    • @KaitouKaiju
      @KaitouKaiju 2 ปีที่แล้ว +4

      @@okinnivlek Wait Linus is behind git?

  • @oleh6738
    @oleh6738 2 ปีที่แล้ว +154

    The folder “.git/log” is not for the command “git log” but for the command “git reflog”.
    timestamp 1:00
    The command “git log” shows commit messages, which are stored in the “.git/objects” folder.

  • @pavelsapehin4308
    @pavelsapehin4308 2 ปีที่แล้ว +49

    00:22 how to investigate .git folder
    00:33 HEAD, etc
    00:50 config folder
    01:00 log folder
    01:20 objects folder
    01:33 what happens on git commit: (1) compress current files with zlib, generates names with sha1
    01:48 3 types of objects: (1) commit, (2) folder view, (3) each file
    02:00 show object type: git cat-file -t
    02:44 show object content: git cat-file -p
    03:06 show object tree: git cat-file -p
    03:34 show file content: git cat file -p
    04:01 summary: what is git object
    04:15 naming in ./git/objects/ (optimization)
    04:56 question: root access/security
    06:09 question: how git handles conflicts
    07:27 index folder: stores what's gonna be your next commit (staged)
    This table of content was created using "Smart Bookmarks for TH-cam" chrome extension.

  • @zvpunry1971
    @zvpunry1971 2 ปีที่แล้ว +97

    To learn about the details, get an old version of git (v1.0.0 or v1.3.0 which doesn't require an old version of openssl's BIGNUM).
    All the commands were simple shell scripts that called simple c-programs that manipulated the index and created the blob, tree and commit objects. "git init" was git-init-db and it created the .git/ directory. "git add" was a shell script that used git-ls-files (a c-program) to get information about the current directory structure and used this information as input for git-update-index. "git commit" was a shell script that let you write a commit message and created the commit object and updated the HEAD reference.
    All these scripts and programs were small and easy to understand.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 2 ปีที่แล้ว +2

      As I recall, one reason why a lot of that simplicity had to go away was because shell scripts and subprocesses do not work well under Microsoft Windows.
      I think this was about the time Mozilla were looking to move to one of these newfangled distributed VCS things (likely they were using Subversion before). But one important criterion was that it had to work well under Windows. Sadly, that ruled out Git (at the time). So they went with Mercurial instead.

    • @warlockpaladin2261
      @warlockpaladin2261 2 ปีที่แล้ว

      BIGNUM?
      Okay, what happened here?

    • @yash1152
      @yash1152 2 ปีที่แล้ว

      thanks a lot for the information you both @zvpunry and @lawrence D'Oliveiro

  • @Rallion1
    @Rallion1 2 ปีที่แล้ว +191

    4:55 NO! Git does not inherently have root access, it only has the permissions of the user which runs the git commands. If you're silly enough to use sudo with git then sure it'll have root access for each command you sudo, but generally it's just your permissions.

    • @JNCressey
      @JNCressey 2 ปีที่แล้ว +20

      I imagine there may have been some confusion such as the folder containing the contents of the repository being described as a "root" folder.

    • @uberDoward
      @uberDoward 2 ปีที่แล้ว +5

      Right, came to see if anyone commented this yet - git works with the same ACLs on the folder as the user that is executing the commands, and that's it. Git has the same permissions as your normal user account, no more, no less.

    • @Alexagrigorieff
      @Alexagrigorieff 2 ปีที่แล้ว +7

      The fun begins when someone does commits or other write operations while a root, then goes back to it without root privileges

    • @caedenw
      @caedenw 2 ปีที่แล้ว +3

      yeah i wanted to point this out too. it was kind of a silly question because most programs don’t deal with permissions security at all. they simple do what they must and the OS manages security by stopping them/you when insufficient permissions arise. then you can choose to elevate permissions or back off. there’s really no silver bullet here but git (and most programs) doesn’t care what user it is running as.

    • @uberDoward
      @uberDoward 2 ปีที่แล้ว +5

      @@caedenw I suspect he was thinking git runs as a service - it does not. That's why all git commands start with 'git ' - you're literally executing git at that point in time.

  • @Dralexus
    @Dralexus 2 ปีที่แล้ว +43

    Max was my lecturer last year and by far one of the best ones in UoN. Thanks you for being such an amazing professor!

  • @joeldriver381
    @joeldriver381 2 ปีที่แล้ว +55

    git runs as the user and is not root unless you run it as root.

    • @faeranne
      @faeranne 2 ปีที่แล้ว +6

      This is important. Most console commands run as the user who invoked them. Special commands can have their SID flag set, which changes who they run as, but most are gonna be as the user who invoked them.

    • @joeldriver381
      @joeldriver381 2 ปีที่แล้ว +3

      @@faeranne Yep and this confuses Windows users 😜. Don't think Windows has an analog of this.

    • @GabrielPettier
      @GabrielPettier 2 ปีที่แล้ว +1

      @@faeranne yep, and generally you want as few as possible commands in your system to have that sid bit set (which means they are going to run as their owner, instead of the user who runs them), even if they have a very specific usage, because it's really hard to ensure your software can't be used to do something unintended, so they can be an important source of security issues.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 2 ปีที่แล้ว +6

      In Windows, the usual answer if some procedure gives you trouble is: “have you tried running it as Administrator?”

  • @IAQMas
    @IAQMas 2 ปีที่แล้ว +62

    The best blockchain!

  • @Polaris64
    @Polaris64 2 ปีที่แล้ว +48

    The recording of a terminal at 0:47 is a bit misleading. There's no need to use sudo when accessing a file to which you have read access (assuming this is the case as the file is within the "pi" home directory) and the path specified ("/Documents/git_test/.git/HEAD") in incorrect, it should be "~/Documents/git_test/.git/HEAD".

    • @Computerphile
      @Computerphile  2 ปีที่แล้ว +23

      Just a reflex action when I was adding some illustrative stuff - you probably guessed but that isn't Max's terminal -Sean

    • @Polaris64
      @Polaris64 2 ปีที่แล้ว +8

      @@Computerphile no worries :) nice to see a Raspberry Pi being used for the demonstrations!

    • @rb1471
      @rb1471 2 ปีที่แล้ว

      @@Computerphile You can use tab to autofill directories/files in the path and the "tree" command is helpful to show the folder structure of small-ish folders.

    • @AdrianColley
      @AdrianColley 2 ปีที่แล้ว +3

      I was alarmed to see `sudo nano`. There's a technical name for that: a footgun. You should only use `sudo` when you're sure you need elevated privileges. In any case, `sudoedit` is a safer way to do `sudo $EDITOR` when it's needed.

  • @rjmaas
    @rjmaas 2 ปีที่แล้ว +16

    I also use Git for keeping backups of my personal documents and my wife's. Git is never intended for that purpose but it works actually great. Especially preventing overwriting newer documents with older versions which tends to happen if you do manual copying files to a backup server or drive.

    • @thexavier666
      @thexavier666 2 ปีที่แล้ว +3

      If your documents are text files, it's perfect for git. But if it's doc, it will still work but will be extremely inefficient.

    • @AlexAegisOfficial
      @AlexAegisOfficial 2 ปีที่แล้ว +2

      @@thexavier666 Only on terms of diffing, since it's not storing deltas, space-wose there's no difference.

    • @lappr0
      @lappr0 2 ปีที่แล้ว +2

      @@AlexAegisOfficial Space wise there is a difference, since your git history also contains all older versions. Since it can't do deltas it contains copies of all older versions.

    • @stt.9433
      @stt.9433 2 ปีที่แล้ว +2

      tbf word also has a version control system.

    • @AlexAegisOfficial
      @AlexAegisOfficial 2 ปีที่แล้ว

      @@stt.9433 I guess that's per document and git manages a whole folder, multiple documents which is the most common usecase, you want related documents (or even all of them) in one place, plus the built in is probably garbage

  • @Baymax007
    @Baymax007 2 ปีที่แล้ว +36

    I love the computerphile videos. If you can make one on docker that would be really interesting. ❤️

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 2 ปีที่แล้ว +61

    7:50 Some people might be accustomed to other VCSes which automatically assume that every change you have made to your working copy is to be included in the next commit (e.g. Subversion works this way). Git doesn’t do this -- it requires you to explicitly _add_ changes to the “index” to be included in the commit. This is because Git recognizes that you often make multiple sets of changes -- for example, while fixing one thing, you notice something else that needs fixing, that is quite unrelated. So when you actually get round to committing your changes, you can pick and choose which ones go into the same commit, and which ones to leave for another separate commit. And some things, like debug message lines, can be left out altogether.

    • @davidfrischknecht8261
      @davidfrischknecht8261 2 ปีที่แล้ว +1

      Some Git client software will allow you to commit changes you haven't added to the index manually. Also, some Subversion client software will let you check in subsets of the changed files in your workspace.

    • @AdrianColley
      @AdrianColley 2 ปีที่แล้ว +5

      My pet theory is that git really grew out of Linus's scripts for managing patch files. The git "index" is really a draft patch message.

    • @Alexagrigorieff
      @Alexagrigorieff 2 ปีที่แล้ว +1

      @@AdrianColley The git index file keeps a complete representation (hashes) of your checked out tree and of the staged tree. To speed up diffing and status command, it also keeps timestamp information of all checked out files.
      When you do "git add", git stores the contents of each file to be staged as a blob, and saves this blob hash in the index (there is an option to just record an intention to stage, without calculating the hash and storing the blob, but it's not normally used).
      When you make a commit, git calculates hashes of all updated (sub)trees in the index and writes those trees as new tree objects. The root tree hash then goes to the commit.
      By the way, you can see the whole history of Git development in its repo.

    • @Alexagrigorieff
      @Alexagrigorieff 2 ปีที่แล้ว

      @@davidfrischknecht8261 The "original" Git command line client allows you to commit without adding to the index. Internally, it just makes a new temporary index file for that.

    • @esquilax5563
      @esquilax5563 2 ปีที่แล้ว

      @@Alexagrigorieff do you mean doing a commit without an add? You can still do that today, just do 'git commit '

  • @puupipo
    @puupipo 2 ปีที่แล้ว +75

    8:06 I'd definitely be interested in watching a Computerphile video about how larger teams use Git and handle merge conflicts and such issues

    • @renejotas
      @renejotas 2 ปีที่แล้ว

      up

    • @abhishek.rathore
      @abhishek.rathore 2 ปีที่แล้ว

      Me too

    • @mcol3
      @mcol3 2 ปีที่แล้ว +7

      But with someone else, this guy is not very clear and always keeps quite vague. Also the previous video was not great, git deserves much better!

    • @abhishek.rathore
      @abhishek.rathore 2 ปีที่แล้ว +2

      @@mcol3 I agree

    • @JerzyMuller
      @JerzyMuller 2 ปีที่แล้ว +3

      In short, private forks and pull requests. Combined with CI builds to validate that it works. We merge about 100 PRs a day at my current project and so far it works fine 🙂

  • @chriswarburton4296
    @chriswarburton4296 2 ปีที่แล้ว +74

    He talks about sending changes between two folders via a server. I'd like to point out that git doesn't actually need/care-about servers; we can push/pull changes directly from one local folder to another if we like; we can make clones of a folder; and so on. I like to have a folder full of "pristine" repos which I pull and push commits to; whilst making and committing changes in separate "working copies" scattered around my computer as needed. We can also send changes back/forth to multiple servers; for example, I host copies of my git repos on my own server, but I also have copies on GitHub (which acts like a "mirror").

    • @ali_p_q7920
      @ali_p_q7920 2 ปีที่แล้ว +1

      That sounds like an interesting way to keep the "official" commits clean and to the point, but you definitely "lose" or "hide" some of the development history, which can be just clutter depending on the quality of those internal committs, so maybe no real loss there.

    • @RoryCrispin
      @RoryCrispin 2 ปีที่แล้ว +7

      Worktrees ought to simplify this workflow for you

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 2 ปีที่แล้ว +8

      I think it is quite common to clean up and simplify your private commit history before sending a bunch of patches to the central authorities for a project. For example, you probably don’t want them seeing every little typo correction or whitespace fixup as a separate commit.

    • @monkeygame7
      @monkeygame7 2 ปีที่แล้ว +10

      @@lawrencedoliveiro9104 Someone tell that to my junior devs ;_;

    • @AndersJackson
      @AndersJackson 2 ปีที่แล้ว +4

      @@ali_p_q7920 that is how you work with Git. You put some stuff in your local copy, clean up the history and push those to the server.
      The thing with GIt is that every user have an own copy of the repository. And when they want, they send the differences to some other user that can merge them into his code base.
      What GitLab/GitHub does is making room for storing those common disk places shared between users.

  • @noredine
    @noredine 2 ปีที่แล้ว +8

    New guy at work got his 1st merge conflict today, and he got frustrated and left

    • @coompiler9029
      @coompiler9029 2 ปีที่แล้ว +6

      Left the room or the job?

    • @noredine
      @noredine 2 ปีที่แล้ว +5

      @@coompiler9029 i'll find out next monday haha

  • @egecav
    @egecav 2 ปีที่แล้ว +25

    I would expect a better explanation from computerphile. A talking man might not be as strong without enough diagrams, animations, demos. Cheers for the dude though, appreciate the explanation.

    • @huqiao
      @huqiao 2 ปีที่แล้ว +2

      I agree, his explanation is pretty rough. There is a Russian guy who does a fantastic job explaining how exactly git works under the hood in details on TH-cam: 3FKrszHcIsA

    • @yash1152
      @yash1152 2 ปีที่แล้ว

      @@huqiao thanks for sharing the video link as well (:

  • @maxdon2001
    @maxdon2001 2 ปีที่แล้ว +4

    Great video!
    I rarely catch a video this early!

  • @florianfanderl6674
    @florianfanderl6674 2 ปีที่แล้ว +7

    It's actually pretty interesting that git always stores the whole file. I thought it would just store the diff of files and reconstruct the latest state by reapplying all changes. Instead they store the state of the tree. Learnt something new today. Thanks ❤

    • @JonasBergling
      @JonasBergling 2 ปีที่แล้ว +2

      By the time git was created storage was cheap enough that I guess it made sense to optimize for speed over space.

    • @florianfanderl6674
      @florianfanderl6674 2 ปีที่แล้ว +1

      @@JonasBergling I always thought that the diff is very central in git. But apparently it's very easy to create, if you can get the complete state of the repo for two commits.

    • @JonasBergling
      @JonasBergling 2 ปีที่แล้ว +1

      @@florianfanderl6674 yeah, it is. But if you keep the complete separate versions of the files it's trivial to run one of the many existing diff tools on them, so why not just do that, I guess.

    • @rjmaas
      @rjmaas 2 ปีที่แล้ว +10

      Git keeps whole copy of the most recent file in its repository. But older versions are often recorded as diffs whenever it makes sense (e.g. text files). Then even older versions are packed into .pack files to make Git even more space efficient

    • @florianfanderl6674
      @florianfanderl6674 2 ปีที่แล้ว +2

      @@rjmaas ah OK. So they still use diffs. Maybe I need to read a bit more 😊

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 2 ปีที่แล้ว +20

    3:41 Tip: You can do “git show --raw «commit»” to get a list of the files affected by that commit. You can similarly list the files affected by each entry in the log with “git log --raw”.

    • @Alexagrigorieff
      @Alexagrigorieff 2 ปีที่แล้ว +1

      It also shows the file renames, which Git is trying to guess.
      For those who don't know, in Git, a commit doesn't store information of file rename. A rename appears as a deleted file and an added file with the same or (not much) different contents.

    • @yash1152
      @yash1152 2 ปีที่แล้ว

      thanks a lot

    • @stt.9433
      @stt.9433 2 ปีที่แล้ว

      Tig does this aswell, on top of showing the differences between each commit.

  • @pierreabbat6157
    @pierreabbat6157 2 ปีที่แล้ว +3

    A Frenchman tried to push a repo when someone else had already pushed a change to upstream.
    «Merge alors !»

  • @MrOboema
    @MrOboema 2 ปีที่แล้ว +4

    No need for a big sluggish relational database. The filesystem is the database. Fast, consistent, works on every system and OS. No overengineering here 👍

    • @yash1152
      @yash1152 2 ปีที่แล้ว

      sure it's fast, but even for my personal bookkeeping purpose, i find it quite limiting.

    • @dealloc
      @dealloc 2 ปีที่แล้ว +2

      Filesystems are not fast for complex operations. Git does relatively simple operations like read/write, but databases are optimized for indexing, processing, storing and querying data relatively often.
      Git is slow in relation to databases for those purposes, but works really well for what it _is_ built for - version control.

  • @guilhermedantas5067
    @guilhermedantas5067 2 ปีที่แล้ว +10

    Please do more videos on git, I find it very interesting and educative!

  • @nikanj
    @nikanj 2 ปีที่แล้ว +13

    Intern: Everythiong the light touches? What about the .git directory?
    Me: That is beyond our boarders. You must never go there.
    Intern: But I thought a develop can do whatever they want.

  • @shazbots
    @shazbots 2 ปีที่แล้ว +11

    Hi, this isn't meant to sound like a complaint, but a suggestion for an improvement. I noticed that the camera is shaking a little bit throughout the interview. It kinda bothers me, but nonetheless, I still enjoyed this video very much!

  • @sneedsfeed757
    @sneedsfeed757 2 ปีที่แล้ว +5

    would love to see even more detailed videos on git plumbing and stuff

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 2 ปีที่แล้ว +11

    5:22 You can set your working directory to any subdirectory of a project directory. Git will automatically go up into parent directories until it finds one containing a .git subdirectory, or until it hits a filesystem boundary, at which point it gives up.

    • @yash1152
      @yash1152 2 ปีที่แล้ว

      thanks for info (:

  • @cornholiooooooo
    @cornholiooooooo 2 ปีที่แล้ว +17

    Kevin Kühnert

    • @Phillip3223
      @Phillip3223 2 ปีที่แล้ว +1

      Siamese twins. Obviously he got the brain while seperation.

    • @tk36_real
      @tk36_real 2 ปีที่แล้ว

      😂

    • @cornholiooooooo
      @cornholiooooooo 2 ปีที่แล้ว

      @@Phillip3223 I've got absolutely 0 patience for a political debate in the youtube comments but I politely disagree with you about the brain thing

  • @connrs
    @connrs 2 ปีที่แล้ว +2

    Erm, those blurred email addresses are readable if you apply a bit of logic

  • @davidmc971
    @davidmc971 2 ปีที่แล้ว +4

    Thanks for the insights into the stuff going on in the background!

  • @n8style
    @n8style 2 ปีที่แล้ว +5

    if 20 people are changing the same file, either that file is far too massive or something's gone very wrong with team communication :D

    • @AileTheAlien
      @AileTheAlien 2 ปีที่แล้ว

      The file could also be riddled with bugs or incomplete features, which would necessitate so many people working on it. :)

  • @jonshouse1
    @jonshouse1 2 ปีที่แล้ว +2

    Good video. You can tell peoples age by them using the term "folder" while typing "change directory", I feel old !

  • @alirezaalavi1504
    @alirezaalavi1504 2 ปีที่แล้ว +23

    can we all appreciate Linus Torvald's level of genius?

    • @anatheistsopinion9974
      @anatheistsopinion9974 2 ปีที่แล้ว +2

      I wish I could tap into some of that genius.

    • @Manuite
      @Manuite 2 ปีที่แล้ว +3

      And of guts when he gave the finger to Nvidia. Did I miss his reaction to Microsoft buying GitHub?

    • @AdrianColley
      @AdrianColley 2 ปีที่แล้ว +2

      Well, OK, but let's not pretend that git's design is any evidence for that genius.

    • @Manuite
      @Manuite 2 ปีที่แล้ว +1

      @@AdrianColley What about linux?

    • @AdrianColley
      @AdrianColley 2 ปีที่แล้ว +1

      @@Manuite That's a much better example.

  • @Flankymanga
    @Flankymanga 2 ปีที่แล้ว

    Marvelous video! As always good job Sean! I am loving Computerphile!

  • @haathimmunas1563
    @haathimmunas1563 2 ปีที่แล้ว +15

    would love to see a video on how teams use git and github, with the push pull workflow and also conflicts

    • @Jonteponte71
      @Jonteponte71 2 ปีที่แล้ว +1

      Google "gitflow" and you will learn how most teams, big or small use git.

    • @haathimmunas1563
      @haathimmunas1563 2 ปีที่แล้ว

      @@Jonteponte71 thanks🙌

    • @AileTheAlien
      @AileTheAlien 2 ปีที่แล้ว +1

      In my experience it's not too complex. Make a feature branch, lots of commits while you build or fix the thing, optionally fix up your branch history, make a pull request on GitHub, merge to mainline. (Or squash-merge to end up with a single bug or feature commit.) Chat software or voice call to talk about conflicts.

  • @tanchienhao
    @tanchienhao 2 ปีที่แล้ว +2

    Does that mean that everytime i run git diff it uncompresses both commits to compare the file contents? Wouldnt that be slow for huge projects? I had thought it wld do it more efficiently with some data structure

    • @AdrianColley
      @AdrianColley 2 ปีที่แล้ว +3

      It actually does have a more efficient structure. Each file is stored in a "reflog" which lets you efficiently extract the delta differences between any two revisions. The commit tells git which revisions to look up.

  • @ilimanjf
    @ilimanjf 2 ปีที่แล้ว +1

    This video would be so much more helpful with visuals. I love your other content with animations and notepad diagrams.

  • @getutill
    @getutill 2 ปีที่แล้ว

    An interesting video for sure. I would appreciate seeing a discussion about the .gitignore file. Thanks for the excellent video!

  • @code-dredd
    @code-dredd 2 ปีที่แล้ว

    *> Git's managing all this stuff, it's probably got kind of root access or something out there. How does that work in terms of security?*
    Git does _not_ have root access to anything. It runs under the same permissions as the user that's using it, so, if your user name is `computerphile`, then Git will run under the same level of access as that user, in the local directory. Git is not a user, and using the `git` command is no different than using the `ls` command or any other external utility. The corollary of this is that _if_ the `root` user is running Git commands as `root`, then Git will be running with `root` privileges. In practice, this means that the owners and access permissions of `.git/` and the files under it will be owned by `root`.

  • @AndersJackson
    @AndersJackson 2 ปีที่แล้ว +3

    Previous hash is a bit like a blockchain.
    You can do clone between directories on the same computer. Or using plain ssh to your account on a server where you only have terminal access (no webserver etc).

    • @AdrianColley
      @AdrianColley 2 ปีที่แล้ว +1

      It's exactly a blockchain!

    • @kwanarchive
      @kwanarchive 2 ปีที่แล้ว +4

      @@AdrianColley And it's the only useful (and valuable) application of a blockchain.

    • @AndersJackson
      @AndersJackson 2 ปีที่แล้ว

      @@__Brandon__ "a bit like", I didn't said it was. ;-)
      Yes, you can rewrite the git history, as you have access and can chain what is the last checked in node in the ledger for that branch. As that start (or latest check in) are stored in git with a link to that node, which links to previous versions. That is how you end up with different branches. There are a link to which hashed node they are located. So when you rebuild the chain, you also set the branches start to another node.
      Blockchains have different ways of get consensus what is the start, so you can't easily chain where the latest log are.
      At least that is my understanding of git inner working.

  • @robmckiernan3264
    @robmckiernan3264 2 ปีที่แล้ว +1

    Brilliant video, very informative and concise :)

  • @DEADLYPiXELEGaming
    @DEADLYPiXELEGaming 2 ปีที่แล้ว +2

    Merge conflicts are the curse of every software developer.

  • @dravarian26
    @dravarian26 2 ปีที่แล้ว +2

    This video could have used a lot more visuals/ examples. It's weird to hear someone talking about merge conflicts, without showing any examples.

    • @AileTheAlien
      @AileTheAlien 2 ปีที่แล้ว

      Especially since git's conflicts are inherently visual. They have arrows and such made out of equals signs and angle brackets, and lots of software will color-code the conflicts vs the normal contents. :)

  • @jean-doe
    @jean-doe 4 หลายเดือนก่อน +1

    awesome and thank's for explantions

  • @freedom_aint_free
    @freedom_aint_free 2 ปีที่แล้ว

    SHA1 has been broken by a Dutch institute past week, it have been considered insecure for at least 4 years, but now is it, it's has been broken.

  • @joshuaruf9807
    @joshuaruf9807 2 ปีที่แล้ว

    "testing 2" is my go-to commit message

  • @Stopinvadingmyhardware
    @Stopinvadingmyhardware 2 ปีที่แล้ว

    What illegal images? OH NO! You’ve got me now!

  • @greyfade
    @greyfade 2 ปีที่แล้ว +2

    The book Pro Git should be mandatory reading for any one who wants to understand Git.

  • @Alexagrigorieff
    @Alexagrigorieff 2 ปีที่แล้ว +6

    I'm afraid this guy doesn't really know what he's talking about.
    'logs' directory doesn't keep "git log". It keeps reflogs for each ref separately - HEAD, each branch under heads/, each branch under remotes/, etc. Reflog is a log of changes of a ref. Every time you make a commit (by "git commit", or amending, or cherry-picking, or rebasing), or reset the current head by checkout or reset command, a record gets added to the reflog. You can show the reflog contents by "git reflog" command. You can find all commits you ever made there, though by default it's set up to expire after 90 days.
    Object's hash refers to its plaintext contents, NOT to its compressed contents. You can use different containers and databases and compression algorithms for storing objects, and their hash will always be the same.
    objects/ subdirectories contain plaintext files, NOT compressed. Each file begins with a line containing the object type and size. Having the object size in the first line protects a bit against constructing a SHA1 collision (which involves appending a tail). Also, having the object type there makes sure objects of different types always have different hashes, even if their bit contents is identical.
    You can pack the objects, they also get compressed and also delta-encoded. The packs will go to objects/packs/ directory.
    "git commit" does NOT zip your files. All it does, it calculates the hash of the root tree of your index, and records that tree hash into your commit object.
    'config' is not a folder, it's a file.
    'index' is not a folder, it's a file. Since it's a local file, "20 people" will never try to add information there, causing need to merge. It's your own local file, independent of other people.

  • @chriswarburton4296
    @chriswarburton4296 2 ปีที่แล้ว +1

    @Computerphile It would be interesting to see a video on "patch theory", which has been used by Darcs (pre-git) and Pijul (more recent)

  • @MattMcT
    @MattMcT 2 ปีที่แล้ว

    This was an awesome chat! Cheers 🍻

  • @MartinMllerSkarbiniksPedersen
    @MartinMllerSkarbiniksPedersen 2 ปีที่แล้ว +1

    sudo nano HEAD to see the content? just cat the file

  • @unconnected
    @unconnected 2 ปีที่แล้ว +1

    I am triggered every time he says folder instead of directory

  • @b2bb
    @b2bb 2 ปีที่แล้ว

    Never thought there was more to learn about version control despite my daily use of it for like the last 5 years of my life.. lol

  • @YeOldeTraveller
    @YeOldeTraveller 2 ปีที่แล้ว

    There is no git service on a client.
    The git process acts on a local git repository (which can be a clone of a remote repository) running at the local user.
    Therefore, it only has the same access to any local objects as allowed by that objects permissions and ownership.
    While it is possible to access a repo on a shared filesystem, this is not the normal process.

  • @ryanjean
    @ryanjean 2 ปีที่แล้ว +4

    The git folder internals is something I use as part of explaining how easy and useful git is, and why git is so lightweight in branching/merging compared to alternatives like TFS. I can also use it to easily fix errors, like deleting/modifying branches quickly.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 2 ปีที่แล้ว +1

      I use .gitignore to ignore files that everybody is likely to see, like build products. I use .git/info/exclude to ignore stuff that only matters to me, like my private “test” subfolder.

    • @Alexagrigorieff
      @Alexagrigorieff 2 ปีที่แล้ว

      I don't think even Microsoft uses TFS anymore.

  • @Elsgarden
    @Elsgarden 2 ปีที่แล้ว +3

    This is the least informative Computerphile video I've seen.. cool, you've showed me some file structures, but didn't tell me how it actually works..

  • @SomeOne-mo7uw
    @SomeOne-mo7uw 2 ปีที่แล้ว +1

    can you skilled guys show us which extensions cant be trusted in browsers (firefox) - I use uBlock Origin, User-Sgent-Switcher, LocalCND, CleaURLS, Containers, Lastpass and Grammarly - and NordVPN on top, but i fear the extensions may be reporting home

  • @MecchaKakkoi
    @MecchaKakkoi 2 ปีที่แล้ว

    Favourite spell: Conflictus resolvio!

  • @richardeadon6396
    @richardeadon6396 2 ปีที่แล้ว

    Saying "minus" when reading command line flags is just going to confuse people. You're adding flags. He even says "dash t" at one point.

  • @dreykim
    @dreykim 2 ปีที่แล้ว +5

    Noice!

  • @stt.9433
    @stt.9433 2 ปีที่แล้ว

    So does every commit have it's own unique tree, or are they all referring the same global one ?

    • @oopss794
      @oopss794 ปีที่แล้ว

      every commit has its own global tree ,
      global tree get changed after every commit

  • @RobLang
    @RobLang 2 ปีที่แล้ว

    Loved the description but the camera movement was awful. I got through to the end but now feel nauseous. Please don't record if you've forgotten your tripod!

  • @thomasstambaugh5181
    @thomasstambaugh5181 2 ปีที่แล้ว +1

    In the section about accessing other resources, I wonder how git handles symbolic links (I assume a linux environment).
    Does anybody know what git actually records when it encounters a symbolic link? I'm especially interested in what happens when it encounters a symbolic link to a file outside the directory tree of the repository ("ln -s /some/other/folder/sensitive_data sensitive_data").

    • @thomasstambaugh5181
      @thomasstambaugh5181 2 ปีที่แล้ว

      @@__Brandon__ Thanks, Brandon. I know what a sym link is and how it is implemented in Linux (and Unix before that). Since presumably git does not record individual inodes, I wonder what mechanism it uses to represent a symlink.

    • @thomasstambaugh5181
      @thomasstambaugh5181 2 ปีที่แล้ว

      @@__Brandon__ : I appreciate your response. I fear I'm being unclear in my language. When a git transfer from one system to another occurs, there are only bits -- no directories, files, links, or anything else -- on the wire. When a git repo is cloned from one system to another, something special must be done with each symlink. The file systems of the origin and destination system of such a clone are likely to be entirely different. Suppose that a repo on system A has symlinks to some targets on system A that are outside the repo. Suppose that repo is cloned to system B. How is each symlink represented in the bits that cross the wire, and how is the representation expanded on system B. What happens on system B if a symlink target is not present on system B when the clone begins -- does git show a broken link?
      Does git, for example, use a text representation that literally expands back into an "ln" command during the clone? I ask because these are sometimes security leaks in Linux systems. I've encountered situations where an attempted symlink fails one way if the target doesn't exist at all and a different way if the target exists and has permissions that block access. The difference between those reveals information about otherwise-private directory structures. If git allows unrestricted use of symlinks, then I wonder if there ways to use its behavior while cloning to similarly leak information about a system.
      I suppose all this goes under the rubric of "injection attack", as in "sql injection attack" -- using carefully constructed abuses of one mechanism to reveal information about another.
      This was all triggered by the brief question about security concerns mentioned in the video (4:55).

    • @jessodum3103
      @jessodum3103 2 ปีที่แล้ว

      @@thomasstambaugh5181 So, in addition to a symlink essentially just being a text file storing the target/destination, there's also the file "mode" which is what distinguishes it from a regular text file. Git also tracks that mode. When you clone/pull a repo, git creates the symlink even if the target/destination doesn't exist (creating a broken link).
      It's no different than if you manually do ln -s to a non-existing target/destination.

    • @thomasstambaugh5181
      @thomasstambaugh5181 2 ปีที่แล้ว

      @@jessodum3103 : Got it, thanks. In the context of the very brief comment in the video about security, this is perhaps worth mentioning. The presence of broken links in a git clone reveals information about the directory structure outside of the directory tree that comprises the git repo. If those links work when they're not supposed to (such as in a misconfigured system), then those links ARE breaches.
      My point here is that some caution is advised when allowing git to commit symbolic links.

  • @nonominox
    @nonominox 2 ปีที่แล้ว

    Now I finally git it.

  • @as-qh1qq
    @as-qh1qq 2 ปีที่แล้ว

    I like exploring hitherto unknown places, where no human has set foot, the darkest dimmest recesses of untouched teritory yet to be found, hidden and harbouring magical secrets -
    in short, *.git*

  • @anishmanandhar3675
    @anishmanandhar3675 2 ปีที่แล้ว

    Ive come across the gitnoire and README files while git init. What are they used for?

  • @vegahimsa3057
    @vegahimsa3057 2 ปีที่แล้ว

    Git manipulated hard links, which a regular user can't normally do himself in the shell (ln -s)

  • @MrRyanroberson1
    @MrRyanroberson1 2 ปีที่แล้ว

    i should mention the cards at 8:16 have poorly balanced volumes compared to the bulk of the video

  • @ximalas
    @ximalas 2 ปีที่แล้ว

    Maybe the next video will visit the pack directory and show both its contents and the contents of the objects directory before and after running git gc --aggressive.

  • @jorgerauljimenez3307
    @jorgerauljimenez3307 2 ปีที่แล้ว +1

    Great video. I had never before thought about how git actually worked. This was truly revealing.

  • @alikellaway3901
    @alikellaway3901 2 ปีที่แล้ว +1

    What version control do the git developers use?

  • @TheEpiCool
    @TheEpiCool 2 ปีที่แล้ว +3

    Git some

  • @thebarnold7234
    @thebarnold7234 2 ปีที่แล้ว +1

    Im going to assume that git uses a linked list data structure. The word HEAD seems like a giveaway.

    • @d5uncr
      @d5uncr 2 ปีที่แล้ว +2

      Yup.
      At 3:48 you see that the commit (except for the initial one) has info about its parent.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 2 ปีที่แล้ว +4

      It’s actually a “directed acyclic graph”. A commit can have a single parent, multiple parents (merge commit) or even no parents at all (like the first commit in a repo).
      Trivia question: can there be more than one commit in a repo with no parents?

    • @Bryft
      @Bryft 2 ปีที่แล้ว

      @@lawrencedoliveiro9104 yes, there's even a --root flag for git rebase, so you can create a new commit without parents if your rebase will modify the original one

    • @Alexagrigorieff
      @Alexagrigorieff 2 ปีที่แล้ว +1

      @@lawrencedoliveiro9104 git checkout --orphan

  • @charksey
    @charksey 2 ปีที่แล้ว

    The blur on the email is not sufficient. It's still readable.

    • @charksey
      @charksey 2 ปีที่แล้ว

      i guess it's not actually a secret though, so maybe this doesn't matter

  • @StanislavPozdnyakov
    @StanislavPozdnyakov 2 ปีที่แล้ว

    Why there is staging area in git?

  • @charliesta.abc123
    @charliesta.abc123 2 ปีที่แล้ว

    This confirms that git is magic.

  • @AlexAegisOfficial
    @AlexAegisOfficial 2 ปีที่แล้ว

    6:50 thats not true either. Git doesn't care about which files are changed. You just can't push to non-existent things. The moment a branch's head is changed on the remote, your local branch head is not gonna be the same thing and you have to update it first. This has nothing to do with the content of the files changed, in fact it could be an empty commit too.

  • @Yupppi
    @Yupppi 2 ปีที่แล้ว

    His favourite chocolate? Git cat.

  • @adia.413
    @adia.413 2 ปีที่แล้ว

    next video: inside the node_modules folder

  • @IceMetalPunk
    @IceMetalPunk 2 ปีที่แล้ว +4

    Merge conflicts are the bane of my existence. For reasons, just a few weeks ago, I ended up with 15 files filled with about 40 merge conflicts at work. It was an absolute nightmare to deal with. So painful.

    • @TheGreatAtario
      @TheGreatAtario 2 ปีที่แล้ว +5

      But even worse than that are changes that aren't conflicts, but which mutually break one another at runtime after they've been auto-merged.

    • @manvesh97
      @manvesh97 2 ปีที่แล้ว

      this happened to me at work too, what's the solution to avoiding this? smaller more incremental commits and more regular merges perhaps?

    • @ryanjean
      @ryanjean 2 ปีที่แล้ว +1

      @@TheGreatAtario It is annoying, but that is why many shops require merging the target (such as master) into the source (such as your feature branch) first in order to check for that, then merging the resulting source back to the target only after you've verified it works. It's an imperfect workaround, because it spaghettifies your merge history, but the alternatives that don't leave a mess in the commit history are often harder to enforce on the more junior developers.

    • @IceMetalPunk
      @IceMetalPunk 2 ปีที่แล้ว +1

      @@manvesh97 Yep. Commit after basically every change, and push only one feature/bugfix per branch, and when starting a new branch always begin with an up-to-date branch that's pulled all the latest changes. That's usually how we work anyway; it's just this one client who wanted changes from a version about 20 minor versions ahead of the one they were using, but didn't want to actually update to that version.

    • @kwanarchive
      @kwanarchive 2 ปีที่แล้ว +1

      @@IceMetalPunk No commit strategy survives in first contact with a customer.
      - General Patton.

  • @ryandward
    @ryandward 2 ปีที่แล้ว

    Any suggestions on a comprehensive course to learn Git?

  • @robust7560
    @robust7560 2 ปีที่แล้ว

    We would really like to see how conflict resolve is actually solved in say a team with 10 or 15 members, computerphile can u create a small video on that ??

  • @madmodder123
    @madmodder123 2 ปีที่แล้ว

    Im confused as to why this is a video but ill watch it anyways

  • @jidechiukor3284
    @jidechiukor3284 2 ปีที่แล้ว +4

    I was just teaching our interns about git and GitHub.

  • @rjhornsby
    @rjhornsby 2 ปีที่แล้ว

    No need for sudo or root privs. git is just a normal command like cat, grep, awk etc. Git commands manage a repository - which is nothing more than a collection files - you own, just like any other files. Everything in a .git/ directory belongs to your user the same as your project/code files. There’s nothing special about .git/ or its contents that requires any root privileges more than any other jpeg or text file.

  • @CardinalHijack
    @CardinalHijack 2 ปีที่แล้ว

    My lecturers at uni didnt even teach us git... we had a group project we were sharing around on a usb....

  • @PhilippBlum
    @PhilippBlum 2 ปีที่แล้ว

    What's the hash based on btw. On the extracted files or the compressed?

    • @Alexagrigorieff
      @Alexagrigorieff 2 ปีที่แล้ว +1

      A hash of an object is run over: 1) a prefix line containing the object type (blob, tree, commit, tag) and size; 2) the object's contents, in plaintext. As you see, objects of different type will have different hash, even if their binary contents is identical. Also, having the object size in the prefix line guards a bit against constructing a SHA1 collision.
      This is also how the objects are stored under .git/objects/XX/ subdirectories.
      The objects can also be packed, compressed, delta-encoded. This doesn't change their hash, since it's always the plaintext hash.

  • @MartinMllerSkarbiniksPedersen
    @MartinMllerSkarbiniksPedersen 2 ปีที่แล้ว +2

    Sorry but this video is not so well research and it is wrong is several ways.

  • @paranoid_android8470
    @paranoid_android8470 2 ปีที่แล้ว

    Ist das Kevin Kühnert?

  • @manateepink9100
    @manateepink9100 2 ปีที่แล้ว

    Oh mein Gott, ist das Kevin Kühnert?!

  • @davorkrpan
    @davorkrpan 2 ปีที่แล้ว

    Please do a whole video on teams using git.

  • @meiowalot7570
    @meiowalot7570 2 ปีที่แล้ว

    config is a text file, not a folder.

  • @LuminousWatcher
    @LuminousWatcher 2 ปีที่แล้ว

    git Hooks next?

  • @cjveeneman
    @cjveeneman 2 ปีที่แล้ว

    editing your email address before creating the examples used in the video would have saved a bit of editing I imagine...:)

  • @oleh6738
    @oleh6738 2 ปีที่แล้ว +1

    git is blockchain technology! Or is it?

  • @laylanala4068
    @laylanala4068 2 ปีที่แล้ว +10

    Investing in crypto now should be in every wise individuals list. In some months time you'll be ecstatic with the decision you made today.

    • @43vkicmop4
      @43vkicmop4 2 ปีที่แล้ว

      Yeah most intelligent word I've heard Crypto is the new gold!! ‌Due to the fall in the stock market, I don't think it's advisable holding, it would be more beneficial and yield more profit if you actually trade on cryptocurrency I've been trading since the dip, and I've made so much profit trading.

    • @stateangel2300
      @stateangel2300 2 ปีที่แล้ว

      How does this whole process works? I'm interested in investing in crypto but still confused by the fluctuations in price🙁?

    • @PoliticsByTabith
      @PoliticsByTabith 2 ปีที่แล้ว

      That won't bother you if you trade with a professional like Mr Christian Thomas Clinton

    • @stateangel2300
      @stateangel2300 2 ปีที่แล้ว

    • @PoliticsByTabith
      @PoliticsByTabith 2 ปีที่แล้ว

      @@stateangel2300 ‌ Yeah, My first investment with Mr Christian Thomas Clinton he earned me profit of over $25,530 US dollars, and ever since thenhas been delivering

  • @kilo.ironblossom
    @kilo.ironblossom 2 ปีที่แล้ว +1

    just an addition: if someone wants to change/add something new to these default cmds behaviour, they can take the benefit of the .hooks/ directory. i.e. prefix/postfixing commit message or not letting you to push, if you have specific strings in the commit like [WIP]

  • @redsnflr
    @redsnflr 2 ปีที่แล้ว

    don't even git me started...

  • @AntiWanted
    @AntiWanted 2 ปีที่แล้ว

    Nice

  • @Richardincancale
    @Richardincancale 2 ปีที่แล้ว +1

    Amazing stuff (!) - exactly the same sort of functionality we had in 1984 when I started working at IBM on an OS with ~400 people working simultaneously on the code.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 2 ปีที่แล้ว

      In those days, it was believed you had to lock files when they were checked out, because if two people made changes to the same file, the world would end or something.

    • @Richardincancale
      @Richardincancale 2 ปีที่แล้ว

      @@lawrencedoliveiro9104 I’m pretty sure we had the ability to have multiple updates to a module. Each module had an owner who was responsible for resolving any overlapping updates.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 2 ปีที่แล้ว +2

      I would have to say, [citation needed].

    • @Richardincancale
      @Richardincancale 2 ปีที่แล้ว

      @@lawrencedoliveiro9104 Tricky that - internal dev team product used in IBM Labs … citation is my memory! Recall that back in 1984 we also had a global network with 30,000 users, email, remote access, file transfer, and a Reddit like system for sharing random stuff. Folk like Mike Cowlishaw invented Rexx as a hobby. There used to be smart people in IBM Labs!

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 2 ปีที่แล้ว +1

      @@Richardincancale I’m sure there were smart researchers at IBM, but somehow their shipping products rarely reflected that -- they were clunky, resource-hungry and overcomplicated compared to, say, DEC and Unix systems.