Creating a .gitignore file - How we can use git ignore to prevent adding unwanted files to git

Поделиться
HTML-код
  • Опубликовано: 4 июл 2024
  • A .gitignore file is a great and simple tool we can use to prevent including unwanted files in a git repository. This file can be used to simply ignore files and directories but also be used to create complex rules and partial rules to ignore select files.
    In this video GitGuardian developer advocate, Mackenzie, runs through exactly how to get started with both a local and a global .gitignore file and shows exactly how the file works. This is designed as an introduction so that you have the knowledge to understand more complex uses for the .gitignore files.
    What is a .gitignore file 0:00
    Creating a .gitignore file 2:09
    Ignoring a file in git 3:06
    Ignoring a directory 3:49
    Ignoring file extensions in git 4:48
    Excluding file path 6:09
    Adding an exception to .gitingore file 6:49
    Ignoring all directories git 7:31
    Ignoring partial name 7:40
    Creating global .gitignore file 8:28
    Who is Mackenzie Jackson?
    Mackenzie is a developer advocate with a passion for DevOps and code security. As the co-founder and former CTO of a health tech startup, he learnt first-hand how critical it is to build secure applications with robust developer operations.
    Today as the Developer Advocate at GitGuardian, Mackenzie is able to share his passion for code security with developers and works closely with research teams to show how malicious actors discover and exploit vulnerabilities in code.
    What is GitGuardian?
    GitGuardian is the code security platform for the DevOps generation. With automated secrets detection and remediation, our platform enables Dev, Sec, and Ops to advance together towards the Secure Software Development Lifecycle.
  • НаукаНаука

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

  • @dustingarner4620
    @dustingarner4620 Месяц назад +1

    Very helpful, thank you!

    • @GitGuardian
      @GitGuardian  3 дня назад

      Thank you for watching and finding it helpful!

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

    Is there a simple way to ignore all .config files in parent folder and subfolders besides writing all paths in parent folder gitignore?

  • @vinitgurjar957
    @vinitgurjar957 9 месяцев назад +1

    The video is really usefull

  • @shake-her3908
    @shake-her3908 Год назад +1

    Thank you :)

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

    For some reason in WIndows 10 vscode, after adding .py file to .gitignore it does not disappear when I run git status. It still appears! I think I have to make a commit first to ignore the file. edit my bad it does work i forgot to add the asterisk. Thanks for the video - liked and subscribed.

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

    Excellent tutorial! Congrats! I just have a question. I've added some audio files to my GitHub repository and now I'm trying to ignore them, but it doesn't work. How can I fix this? I've been trying everything but I couldn't resolve it. can you help me?

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

      If I understand correctly, you have already pushed audio files to GitHub and you are trying to remove them?
      Here is a tutoiral on rewriting git history that might help ruclips.net/video/msUDPYsbABY/видео.html

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

    I just recently installed git and trying to learn it but when I do git status why does it show desktop.ini files. Can u please make a video on it to resolve them so that they don't interfere in future too ??? I have heard that it's due to I don't know Google drive errors...

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

      The Windows operating system automatically generates a desktop.ini file upon changes to a folder. the equivalent on a Mac OS is the .DS_store file. Both these files can be added to the .gitignore file to prevent them from being cached by git (which is recommended), I would suggest adding them to a 'global' .gitignore file so they are ignored in all files simply add desktop.ini in the .gitignore file itself.
      If you want to delete these files that have already been pushed to a git repository you will need to rewrite your history, a video on how to do that can be found hereruclips.net/video/msUDPYsbABY/видео.html

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

    Hello bro, I have been investigating to solve my problem but I can't find an answer. I want only and exclusively to have in my github .c, .h, .cpp files, etc. My text editor (SublimeText) configured for competitive programming in CodeForces/SPOJ of C++ generates files without extension, without dots let's say.
    They tell me to add this to .gitignore
    *
    !/**/
    !*.*
    But it doesn't work. Recommendations?

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

      Sorry I'm not sure I completely understand the problem. You want to ignore all flle that do not have a file extension?

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

      ​@@GitGuardian
      Indeed, when I am executing scripts/programs given that I have SublimeText with certain configuration, only "file" feature files are generated, they do not have any extension.