The Git Index Explained How to stage a file with Git add

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

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

  • @pravinprince3221
    @pravinprince3221 11 месяцев назад +1

    Thank you sir for the wonderful video we love all your git videos so much it taught us so much, thanks again sir

  • @magicteen1
    @magicteen1 2 месяца назад +1

    Hey man, appreciate your video but unfortunately it’s not technically accurate. Index contains not just modified or new files. It contains ALL files that go into next commit. You don’t have to explicitly add unmodified files since by default index starts out matching previous commit.
    This explains why you have to remove a file from index if you don’t want it to be part of next commit. (Removing from working directory does nothing as far as git is concerned.)
    Also, when you add a file to index, git does much more than just record its pathname. It creates an internal copy of the file (a so-called blob), and it is that copy that the index references. This explains why modified files have to be re-added to index (even though their pathname is already in the index).

    • @cameronmcnz
      @cameronmcnz  2 месяца назад +1

      You're hired! Yes, what you say is correct. I indeed glossed over the more technical aspects to simplify the concept, but you are 100% correct. Maybe I'll re-record this and focus on what's technically going on below the covers.

  • @scrumtuous
    @scrumtuous Год назад +1

    Never understood why we had to do git add all the time and add things to the git index. Makes no sense to me.

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

      It's a common confusion when people start out with git, but eventually you just get used to using the git add command and staging files before a commit.