Git Ignore All Except Some Files

If you already have a .gitignore file with rules, you can change them.


My .gitignore looked like this;

#ignore these folders
scripts/
lib/**
logs/

# ignore these files
.sql 

Let's say you now want to include a file located at /lib/config.php. You would add this line;

#ignore these folders
scripts/
lib/**
logs/

# ignore these files
.sql

# allow
!lib/config.php 

Next run git status and you should see ;


untracked files 

/lib


Now you can run git add lib/ 


After another git status you should see;


new file:  lib/config.php

modified: .gitignore


Then add both files git add . 


From here you can commit and push to the remote repo.



MySQL Check All Tables in Database
MySQL Repair All Tables in Database
 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Guest
August 6, 2020

Captcha Image

By accepting you will be accessing a service provided by a third-party external to https://www.johnnyshongo.com/