Git Internals - How Git Works - Fear Not The SHA!

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 123

  • @glebkoshelev
    @glebkoshelev 5 лет назад +119

    aside from "AHA! moments" there are "hell yeah!" moments when you manage to find a clear and short educational material that covers core conceptual model, so that you wouldn't have to read docs to figure out the gist of it! I love docs, but life is too short to read them all) Thanks a lot! You've saved two days of my life! Multiply that by the number of views ~13k and you've got almost one human life saved!) Great job!

  • @AkshayAradhya
    @AkshayAradhya 2 года назад +13

    Man we need more of these intermediate in-depth tutorials. So well made.
    Every other video tutorial just talks about basic git stuff branches, commits, etc.

  • @usoppgod8107
    @usoppgod8107 3 года назад +25

    I cannot stress enough how wonderfully things were explained. Cheers man!

  • @cyantarek5457
    @cyantarek5457 Месяц назад

    This is the best ever low level internals explanation on how git works (like Ben Eater). A gift for us low level fans

  • @LeeZhenYong
    @LeeZhenYong 3 года назад +11

    This is so well explained! I got a deeper appreciation of how cleverly designed git is.
    I never knew each time I do git commit it tracks every single file; imagine a project with hundreds of files!

  • @lynndemarest1902
    @lynndemarest1902 6 лет назад +135

    What did that poor keyboard ever do to you? :)

    • @artembordiuh2802
      @artembordiuh2802 4 года назад +10

      Wonderful tutorial! But the Whac-A-Mole game with the keyboard is very loud.

  • @shyamgadepalli9786
    @shyamgadepalli9786 5 лет назад +4

    Great video! Explains in detail how Git works under the hood. The last two examples were an icing on the cake. Thanks for putting this together!

  • @andyd568
    @andyd568 11 месяцев назад

    Beyond helpful because of its level of detail and precision.

  • @vil9386
    @vil9386 3 года назад

    wow, so glad I watched this. This 30min gave me so much insights of git design (hands-on way!!) and it made git usage instantaneously easier. THANK YOU!

  • @ansadahmad1958
    @ansadahmad1958 6 месяцев назад

    Thank you sir for this video! Your efforts into making a simplified free video is much appreciated by us all curious learners!!

  • @Igor160193
    @Igor160193 2 года назад

    I never feared the SHA, but now I understand the SHA. Thank you

  • @komalvenkatesh4527
    @komalvenkatesh4527 5 лет назад +6

    Great video. Exactly what I was looking for! Thank you. Every so called "weird/scratch your head" moment in git makes sense now.

  • @melisoner8981
    @melisoner8981 4 года назад

    I wasn't afraid of the shas before but this took it to a different level. Thank you.

  • @MrHav1k
    @MrHav1k 4 года назад +2

    I'm not even a developer, just an infrastructure guy, but this was an excellent explanation.

  • @KiLVaiDeN
    @KiLVaiDeN 3 года назад +1

    Very interesting tutorial on how the .git folder is impacted by some basic git commands internally, for me it's as important for a git user than knowing how a cpu works for a developer :) Thank you David for this introduction, it will for sure allow me to understand and research about even deeper plumbing of git in the future :)

  • @bulletbeatboxer
    @bulletbeatboxer 2 года назад

    I send all my new devs this video! SO key in understanding how to use git.

  • @prasadkailkeresridhar8316
    @prasadkailkeresridhar8316 4 года назад +1

    Brilliant demo of the internals of git! thanks for the information...helps with a good foundation knowledge to understand git commands..thank you David for helping understand.

  • @TeenyPort
    @TeenyPort 4 года назад +2

    awesome video so far, but I believe around minute 19:20 when you say "this commit points to 2 files" you are actually talking about the new tree pointing to foo.txt and bar.txt

  • @JiaweiCao
    @JiaweiCao 4 года назад

    Thank you! You explained what happens in git internally in a very easy and clear way!

  • @PauloMesquita2067
    @PauloMesquita2067 10 месяцев назад

    I'm a little late to the party but:
    If this is "the information manager from hell" I can't imagine how the others are..... 🙂
    Great job on explaining the object structure and how git does things in a practical and simple manner. Thank You Ver Much!

  • @emadpres
    @emadpres 4 года назад

    Fantastic tutorial! Now it's clear to me when we say Git doesn't store diffs.

    • @majorgnu
      @majorgnu 4 года назад

      It kinda does in pack files, but only as a space-saving optimization, not as a part of its core model.

  • @jonathanlamb8789
    @jonathanlamb8789 3 года назад

    Really clearly explained and well presented - thanks for creating this!

  • @architgupta4087
    @architgupta4087 5 лет назад +3

    Amazing. Cleared a lot of things for me.

  • @p-a5603
    @p-a5603 3 года назад

    This took me an hour. 30 minute watching git internals video, 30 minute writing python function handling creating/deleting folder with 100 files :D

  • @ekbastu
    @ekbastu 3 года назад

    Hey Thomas, you made my day. Thank you so much .

  • @deltonvaz7126
    @deltonvaz7126 5 лет назад +5

    Amazing video! RIP keyboard

  • @KelvinTrambadiya
    @KelvinTrambadiya 6 лет назад

    Thanks much.! Really helps a lot to start understand internals and data structure behind it.

  • @ahmedbenziada9784
    @ahmedbenziada9784 6 лет назад +1

    Wonderful explanation. That's what I was looking for. Thanks man.

  • @parthbhimani9778
    @parthbhimani9778 4 года назад

    Thank you for this. Clearly understood the basic internal workings of git.

  • @HarshKapadia
    @HarshKapadia 3 года назад

    Awesome talk, David! Thank you!

  • @lorenzoluisalbano3695
    @lorenzoluisalbano3695 Год назад

    Beautiful. Looking at the hashes and the contents of each file referring to (or named after those) hashes you begin to gain understanding... of just what the eff they have got inside, what they are supposed to be, and what they are connected to. So explicit that pleases and hurts. Kudos for teaching us the most important git command (and how to refer to each of them by the first 6 digits of the hash.): $ git cat-file -t dc23ab / git cat-file -p dc23ab

  • @nneddenn6207
    @nneddenn6207 Год назад

    Nice and crisp explanation! It was good

  • @amirrezalotfi8919
    @amirrezalotfi8919 2 года назад

    Awesome video!!!!! It is exactly what I was looking for.

  • @JeffreyDeveloperCOL
    @JeffreyDeveloperCOL 5 лет назад

    Thanks for this excellent video. Awesome the last surprise part

  • @RohitSoni1
    @RohitSoni1 Год назад

    Goes deep on just one thing ..what's behind the 40 char SHA and makes it easy!! Thanks much!! 😊

  • @nickV703
    @nickV703 3 года назад

    So many aha moments! And so well explained!

  • @tigranrostomyan9231
    @tigranrostomyan9231 5 месяцев назад

    This is CRAZY. Thank you so much!

  • @yeoahjang5695
    @yeoahjang5695 4 года назад

    Awesome video, loved the exercise, I learned a lot from it, thank you!

  • @UPPERKEES
    @UPPERKEES 6 лет назад +2

    What I still don't understand is how git is able to change the file system view. When you cd into a directory, you'll see the files/dirs of that commit reference. When you go to a different git branch, the file system view changes along with it. ext4 and other file systems also use references (inodes) to display files. Is git just a sort of overlay file system? If so, how would that work with so many different file systems and operating systems?

    • @TheHowlTube
      @TheHowlTube 6 лет назад +4

      It really doesn't make any special changes to the file system itself - it's not FUSE. When you git checkout a branch, it first changes the HEAD to be the new hash or the new branch. Once the HEAD is sorted, it'll go ahead and figure out what changes it needs to make to your worktree. After that, it's a matter of changing all the files in the directory, which can be done without knowledge of the filesystem.

  • @baharalirezaei3608
    @baharalirezaei3608 5 лет назад +1

    Great explanation,Thanks a lot🌺

  • @DennisAllard
    @DennisAllard 5 лет назад

    Outstanding presentation of the fundamental git add/commit semantics. Do you have a overview video on fetch/merge/pull?
    Suggestion: you mention branches in the intro and towards the end of the presentation you give a simple example of creating a new branch (named foobranch). It would be useful to point out the effect of the first commit of foobranch to HEAD and the pointer values of foobranch and master both before and after the commit. That all begs for a second excellent video on branching.
    The subtleties of file timestamps are also interesting to comment on. Hint, Git does not record file timestamps.
    BYW I like the sound of your keyboard. (-:

  • @prakashk78
    @prakashk78 6 лет назад

    Thank you , all of git commands are playing with tree, blob, commit object :) thanks for nice explaination

  • @tileq
    @tileq 3 года назад

    Excellent presentation.

  • @ws9691
    @ws9691 3 месяца назад

    Awesome explanation!

  • @shayestaparveen315
    @shayestaparveen315 4 года назад +1

    This video is amazing! Thank you so much.

  • @asadmoosvi
    @asadmoosvi 4 года назад

    Fantastic content. Learnt a lot from this.

  • @NicolasIvanov
    @NicolasIvanov 3 года назад

    AHA moment worked, thank you!!

  • @tanchienhao
    @tanchienhao 2 года назад

    Awesome lesson!!

  • @RossiMurilo
    @RossiMurilo 3 года назад

    Great content! Thanks for sharing!

  • @ueiwqoak
    @ueiwqoak 2 года назад

    Great video. Is there a software tool to visualize ALL the sha references?
    I know you can see the commit DAG, but I want to see the commit+tree+blob DAG, like what was visualized at @10:37

    • @ueiwqoak
      @ueiwqoak 2 года назад

      Like are there any pyviz like tools that can automatically generate the clean, beautiful diagram you made at @10:37 but for and Git repo?
      It’s clear you could make the diagram by crawling through the objects file but that seems frustrating and unnecessary

  • @akimbbo_upnext
    @akimbbo_upnext Год назад

    So lets say if in my git repo in i would make a change in every file each time i do a commit then git would have to allocate space on disc equal to how much space repo does take (more or less) and multiply it by number of commits?
    Also great video!

  • @sergiomorenosuay3030
    @sergiomorenosuay3030 2 года назад

    Fantastic video!

  • @majorgnu
    @majorgnu 4 года назад +1

    9:50 "The contents of these files is *encrypted"*
    That's not the term you were looking for.
    Git storing objects in a compressed, application specific format is not a form of encryptiom.

    • @abdulmatin3208
      @abdulmatin3208 4 года назад

      It should be like that right? "Git stores the content in a compressed format and creates the SHA1 based on the compressed contents meaning compressed data are the parameter to produce the sha1 keys"?

    • @majorgnu
      @majorgnu 4 года назад +3

      @@abdulmatin3208 SHA1 is not a cypher. It doesn't encrypt stuff.
      SHA-1 is a cryptographic hash function.
      A hash function maps data of a variable size to values of a fixed size (hashes) - 20 bytes long in the case of SHA-1.
      The "cryptographic" part means that it's considered to have a set of properties that makes it useful in cryptographic applications.
      Perhaps the most important property being that it's very hard to find hash collisions, i.e. two inputs that produce the same output.
      Git uses SHA-1 as the hash function of its *content addressable storage* system.
      Content addressable storage is a way to organize stored data where the identifier for a piece of data (a git object in our case) is derived from the data itself.
      To summarize: git objects are stored is a simple, unencrypted format that happens to use compression to save space. SHA-1 is only used to *identify* the objects in git's content addressable storage system.

  • @roycechristongoveas5836
    @roycechristongoveas5836 Год назад

    Crazy video amazing explanation 🤩

  • @RahulGupta-wd3lf
    @RahulGupta-wd3lf Год назад

    So just to be clear there are duplications in blobs every time we change a file?

  • @ChrisAthanas
    @ChrisAthanas Год назад

    12:57 this is how the video should start Ave then the slide show after or in between the code and slides
    The slides are eye glazing material without the code

  • @rajbopche7992
    @rajbopche7992 4 года назад

    In your Git model PDF you showed a single commit having multiple trees following parent-child pattern. However, practically when you showed the contents of a commit it just held reference to one single tree + one single tree only held reference to one/multiple blobs. What are we missing ?

    • @jamesburgess9101
      @jamesburgess9101 4 года назад +1

      tree objects are flat lists of references. References to both blobs and other trees. If the db needs to represent a sub-directory in your repo you would see a tree reference inside a tree. The example did not have any files in sub-directories.

  • @pgangloff
    @pgangloff 5 лет назад

    Thank you! [bibs on the wall=trail?] I'll google some more and try it for myself but it would be great to see an example where you rename a file. I think in those cases, we lose the history of the changes to a file? i.e: this would be considered "deleted a file" + "added a file". I'm not sure I understand Linus' philosophy on that one... That's where I'm still confused... Just starting up on git; our team uses SVN and, migrating to git, many are worried that git "loses commit history" when refactoring/renaming files. [ignore svn2git issues, I'm talking about a project already in git]

  • @kennethcarvalho3684
    @kennethcarvalho3684 Год назад

    This was very helpful in understand ing git.. Thanks

  • @giscardboulou5886
    @giscardboulou5886 6 лет назад +5

    why you so angry at your keyboard man! For real tho it's distracting :) good video!

  • @blackhalo117
    @blackhalo117 3 года назад

    Thank you very much for this video!

  • @biplavtimalsina9644
    @biplavtimalsina9644 4 года назад

    Such a good video. Thanks ton man!

  • @_ashout
    @_ashout Год назад

    It's crazy I really thought that internally git would store diffs.

  • @gustavomuller7190
    @gustavomuller7190 8 месяцев назад

    Great video!

  • @vedantneema
    @vedantneema 2 года назад

    amazing explanation

  • @haccks.
    @haccks. 3 года назад

    How come git add results in adding blob to the objects directory? Shouldn't it be done after running git commit command?

  • @navinmeshram7541
    @navinmeshram7541 4 года назад

    The famous Butterfly keyboard it is.

  • @AliAnwarwish
    @AliAnwarwish 4 года назад

    Thanks a lot. Very informative video.

  • @arindammukherjee3261
    @arindammukherjee3261 4 года назад +1

    Start at 3:40.

  • @amarjawla
    @amarjawla 3 года назад

    Amazing video .. cheers !!

  • @harshraj22_
    @harshraj22_ 4 года назад

    I read that sha1 is a cryptographic algo, for which encrypting is easy, but encrypting from encrypted is nearly impossible. If git hashes all contents to sha1 hashes, how does it decrypts the contents so fast and correctly while say changing branch ?

    • @Knirin
      @Knirin 3 года назад

      Git doesn’t store the objects in an encrypted form. They are compressed and the hash is used as a name in a phone book to look them up.
      You can’t decrypt a sha1 hash into its original input you can however find another input that will give the same hash. This is called a collision. Password cracking is looking for variants on known passwords and the dictionaries of various languages to find words that have matching hashes. The longer and more random a password is the more attempts are required to find a match.

  • @christiansakai
    @christiansakai 5 лет назад +1

    This is what I need!

  • @sureshkumar-hu3ld
    @sureshkumar-hu3ld 4 года назад

    Awesome. Really useful

  • @FugalBaboon
    @FugalBaboon 2 года назад

    Confused why he kept re-adding files (git add ....). In all my git experience I add it the first time and never have to add again.

  • @gagangupta1255
    @gagangupta1255 4 года назад

    Awesome video

  • @sydneysights8697
    @sydneysights8697 Год назад

    Excellent !!

  • @daya0576
    @daya0576 6 лет назад

    Thx a lot, glorious tutorial!

  • @LaurenceBrown-rx7hx
    @LaurenceBrown-rx7hx 3 года назад

    Does anyone know what music was used for the intro?

  • @coreyp.789
    @coreyp.789 4 года назад

    Very nice! Thanks.

  • @hyperbitcoinizationpod
    @hyperbitcoinizationpod 3 года назад

    Is git also making a chain of hashes, like a blockchain?

  • @thats-no-moon
    @thats-no-moon 2 года назад

    This is gold

  • @rohit1987j
    @rohit1987j 6 лет назад

    nice way of explanation.

  • @AliAnwarwish
    @AliAnwarwish 4 года назад

    How to view the content of blob if it's not text file? Just say it is image of zip file or something.

  • @kushagragautam3979
    @kushagragautam3979 6 лет назад

    What is the purpose of local repository?
    Let's take a case that we have central repository and our workspace only. What difference will local repository make?

    • @TheSrishanbhattarai
      @TheSrishanbhattarai 6 лет назад

      You might want to check out Linus Torvald's talk on Git, particularly where he emphasizes the distributed nature of Git, and how it's superior to centralized version control systems like SVN etc.

  • @prashantvaishla499
    @prashantvaishla499 5 лет назад

    very informative . thank you

  • @aquere
    @aquere 5 лет назад

    Thank you for this video

  • @iblockdev7342
    @iblockdev7342 6 лет назад

    is there any alternative to watch command on windows and mac os x?

  • @GintsPolis
    @GintsPolis 7 лет назад +1

    Thank you!

  • @Aarmaxian
    @Aarmaxian 3 года назад

    Too good to be true!!

  • @italian_boy402
    @italian_boy402 5 лет назад

    What utility did you use to split the shell?

    • @AliAnwarwish
      @AliAnwarwish 4 года назад

      1. He's using screen command. You need to install it by "apt install screen".
      2. I would suggest you to intall terminator on linux. It's a very smooth terminal splitter and works like charm.

  • @alexandersviridov8682
    @alexandersviridov8682 3 года назад

    brilliant!

  • @NLmkkillah
    @NLmkkillah 5 лет назад +1

    This would be amazing if it would've been correct since you say trees have the complete current state as blobs, but at 11:05 you show trees pointing to other trees.

  • @eashanmathur2030
    @eashanmathur2030 4 года назад

    Thanks sir 🙏🏼

  • @idc19
    @idc19 4 года назад

    Thank you

  • @techwithraj11
    @techwithraj11 Год назад

    stupendous

  • @rdd13r
    @rdd13r Год назад

    It's "working copy" not working directory

  • @shivanshhanda7553
    @shivanshhanda7553 4 года назад

    What terminal is he using? Doesn't look like gnome-terminal

    • @AliAnwarwish
      @AliAnwarwish 4 года назад +1

      1. He's using screen command. You need to install it by "apt install screen".
      2. I would suggest you to intall terminator on linux. It's a very smooth terminal splitter and works like charm.

    • @shivanshhanda7553
      @shivanshhanda7553 4 года назад +1

      @@AliAnwarwish thanks.

    • @AliAnwarwish
      @AliAnwarwish 4 года назад

      @@shivanshhanda7553 Hey bro. You can install tmux too. I'm using it rn.

    • @shivanshhanda7553
      @shivanshhanda7553 4 года назад

      Hey man, I switched back to gnome-terminal as terminator was showing strange characters when using. Will give tmux a try, thanks.
      Edit: Also, I found gnome-terminal to be faster than terminator, eg when I cd to a big git repo, terminator takes more time to load.

    • @AliAnwarwish
      @AliAnwarwish 4 года назад +1

      @@shivanshhanda7553 Yes I do agree. But tmux is better at session management too. Yeah nice, worth a try.

  • @majorgnu
    @majorgnu 4 года назад

    Saying that git is a DAG sounds like a challenge to researchers working on intentional cryptographic hash collisions.
    It's all fun and games until someone finds a commit that has itself as a parent. :)

    • @Knirin
      @Knirin 3 года назад

      Replacing sha1 with a different hash algorithm wouldn’t be difficult. You can use the bit length of the hashes to distinguish them. Compatibility might be a pain temporarily.
      I am not sure if the known attacks on sha1 allow constructing arbitrary input that collides.

  • @hsaidinsan6345
    @hsaidinsan6345 4 года назад

    20:45
    Doug DeMuro This is the new Bmw x5 ......

  • @mvizavis6351
    @mvizavis6351 2 года назад

    Voila !