There are some great answers already, but my situation was tedious. I'd edited the source of an installed PLM (product lifecycle management) software on Win10 and afterward decided, "I probably should have made this a git repo."
So, the cache option won't work for me, directly. Posting for others who may have added source control AFTER doing a bunch of initial work AND .gitignore
isn't working BUT, you might be scared to lose a bunch of work so git rm --cached
isn't for you.
!IMPORTANT: This is really because I added git too late to a "project" that is too big and seems to ignore my .gitignore. I've NO commits, ever. I can git away with this :)
First, I just did:
rm -rf .git
rm -rf .gitignore
Then, I had to have a picture of my changes. Again, this is an install product that I've done changes on. Too late for the first commit of the pure master branch. So, I needed a list of what I changed since I'd installed the program by adding > changed.log
to either of the following:
PowerShell
# Get files modified since date.
Get-ChildItem -Path path\to\installed\software\ -Recurse -File | Where-Object -FilterScript {($_.LastWriteTime -gt '2020-02-25')} | Select-Object FullName
Bash
# Get files modified in the last 10 days...
find ./ -type f -mtime -10
Now, I have my list of what I changed in the last ten days (let's not get into best practices here other than to say, yes, I did this to myself).
For a fresh start, now:
git init .
# Create and edit .gitignore
I had to compare my changed list to my growing .gitignore, running git status
as I improved it, but my edits in .gitignore are read-in as I go.
Finally, I've the list of desired changes! In my case it's boilerplate - some theme work along with sever xml configs specific to running a dev system against this software that I want to put in a repo for other devs to grab and contribute on... This will be our master branch, so committing, pushing, and, finally BRANCHING for new work!