Git and Github Tutorial - Ignore Files - Part 7

Hi, Today in iThePro we will learn how to use Git and how to use with Github to build software and develop it. In this part we will see how to using the ignore file.



Using the ".gitignore" file:
<project>/.gitignore
this file Contains roles to till git witch files should be ignored, using basic regular expression.
* ? [aeion] [0-9]
! (it's mean NOT)
Example

*.php                    // ignore all php files
!index.php           // DON'T ignore index.php
game/videos/      // ignore all files
 What to ignore:
-Compiled Source Code.
-Packages and Compressed files.
-logs and databases.
-Operating System (OS) generated files.
-Users uploaded assets (images,PDFs,videos...).

See Some .gitignore example based on language
https://github.com/github/gitignore

Note : don't forget to add and commit the ".gitignore" file.

Globally ignoring files:
->ignore files in all repository on the local machine.
we do this with global gonfig:
touch ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
 To configure the ".gitignore_global" is the same as the ".gitignore"

Ignoring tracked files:
Once we want to stop tracking files and ignore them from the repo. We can't do this with the ".gitignore" file, we need to remove it from the staging index and add it to the ".gitignore" file.
git rm --cached <file-name>
 this will remove it from the staging index, and then we need to added to the ".gitignore" file and finally commit them !

Tracking empty directory:
Git doesn't track empty directory.
So in order to make git tracking them, we need to add a hidden file ".gitkeep" in the directory we want to track and with editing this file just ".gitkeep".


See the Git and Github Tutorials.


Author

OUSSAMA AMRI

Oussama Amri 21 years, security professional from Tunisia. Lover of computer science especially programming and secuirty. Follow me On :

Popular Posts

iThePro.com. Powered by Blogger.