how to restart a git repository

JimH picture JimH · Mar 6, 2013 · Viewed 34k times · Source

I am a newbie with git – and just realized changes to the .gitignore does not process against the repo “retroactively” – rather affect future ‘git add *’ commands and the like. Once the files are in the repo – they must be manually removed.

At this point – I would like just kill this repo entirely – and start over (saving my config, etc.).

Is this easily possible or would it cause major problems? Can backup – then delete the .git folder – and start fresh?

Also – for others newbies just starting in git I would suggest viewing this video. It describes not how to use git – but how git works internally – and I found it eye opening. It’s titled git for ages 4 and up. http://blip.tv/open-source-developers-conference/git-for-ages-4-and-up-4460524

Resolution:

I want to thank everyone for their input and guidance.

I did try to delete the .git directory - and restart. I am not sure how - but when I did try to start it over - It started up with full awareness of it's history - and in short recreated itself to include all the previous commits and tracking.

I left that alone - and set about reorganizing and restructuring and cleaning. Changing the folder structure - deleted unnecessary projects, folders, etc.. - and in the process - realized what I could do to remove the files I did not want tracked (but still wanted them present in the tree).

I effectively moved every folder, etc. and when I would commit this - git removed the tracking on the moved / deleted files. But because of the .gitignore I now had - it did not pick up or track the files in the moved folders.

Much of what I was doing was in preparation to start a whole new git repo. Late in the process I't dawned on me - most of what I did not want tracked had been effectively been removed for the repo. So took what had happened - and made a few more adjustments - and all is fine now.

Once again - thank you. I'm loving git!

Answer

JohnNY picture JohnNY · Mar 6, 2013

I do this all the time. got into the working directory and if your on linux or mac do a

rm -rf .git

then I do a

git init
git add .
git commit -m "first time load"

that's all you need