git ignore :
- whenever programmers develop a project, rather than source code, developers uses a lot of third party or development files like logs, class files , they don’t need in source code when we pushing to remote repository
- here we can use .gitignore, create a file with .gitignore in the working directory.
- add eliminated files like *.log or *.class , *.dev , save file ,
- when you add git add . , it won’t add log, class, log.
We can see with demo example:
(i) Created gitignore folder, and moved in to it
mkdir gitignore |
cd gitignore |
(ii) Created log files : tests.log, update.log, status.log files with in the folder
touch tests.log, update.log, status.log |
(iii) Created normal files : styles.css, support.js
touch styles.css, support.js |
vim .gitignore |
Press I to insert modeAdd*.log*.logsSave it by pressing ESC, next wq! |
(v) Initialising the directory as git repository
git init |
(vi) Adding all files to staging area
git add . |
(vii) Checking what files are added to staging area
git status |
(viii) Observation:
We can see only styles.css, support.js are added to staging area
Files having extension .log are skipped for moving into staging area