Changes

Jump to navigation Jump to search
917 bytes added ,  14:05, 24 July 2015
adds recipe for ignoring directory with exception
<source lang="bash">
git log --stat
</source>
 
How do you ignore a directory, but make an exception? What if you already added certain directories to git but want to stop tracking them now (ie. "take them out of version control")?
A combination of editting your <code>.gitignore</code> file and <code>git rm --cached</code> to the rescue. I had accidentally added and committed some files into git which should have been ignored because they are 3rd party files managed by [[Composer]]. I fixed my <code>.gitignore</code> to track only what I want while ignoring a parent directory:
 
<pre>
/nbproject/*
# ignore everything in the 'vendor' directory
/vendor/*
# but don't ignore the 'eqt' directory
!/vendor/eqt/
</pre>
Then you simply remove all files from git's index, and add them back (only now adding them back will look to .gitignore for the corrected rules)
<source lang="bash">
git rm -r --cached .
git add .
git commit -m 'ignoring vendor/*'
</source>
[[Category:Development]]
4,558

edits

Navigation menu