DevOps Classroom Series – 18/Sept/2020

How to ignore files in git

  • Many languages when we use it for coding, they will have
    • binary files
    • temporary files
  • These files we will never add to git.
  • To ignore files or directories, create a .gitignore file in teh git repository and add all the exclusions over there
  • Navigate into any dummy repo (Which is created for practice)
mkdir bin
mkdir logs
# create 100 log files
touch logs/{1..100}.log
# create 100 binary files
touch bin/{1..100}.exe
touch bin/{1..100}.txt

  • Execute git status Preview
  • But if we want to skip all the .log files. Create a .gitignore file and add the lines & execute git status
*.log

Preview

  • Now lets ignore folders. Ensure your gitignore has the following lines & check status
#ignoring log files
*.log

# ignoring bin directories & its contents
bin/*

Preview

  • There is a website that can help you generate gitignore Refer Here

Viewing Staged & Un staged Changes

  • Consider the following state for your repository Preview
  • Execute git diff to view the changes of the files which are in modified state Preview
  • Now lets add only modified files to the staging area Preview
  • Lets add the changes to the staging area and view the differences in staging area (staged vs unmodified) Preview Preview
  • To move the changes to local repo directly Preview
  • Removing the files Preview
  • Rename the files Preview
  • Moving the files Preview

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin