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
  • But if we want to skip all the .log files. Create a .gitignore file and add the lines & execute git status
*.log

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

# ignoring bin directories & its contents
bin/*

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

Viewing Staged & Un staged Changes

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

Leave a ReplyCancel reply

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

Please turn AdBlock off
Plugin for Social Media by Acurax Wordpress Design Studio

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%