Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to restart a git repository

I just realized that changes to the .gitignore do 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 I backup – then delete the .git folder – and start fresh?

like image 399
JimH Avatar asked Mar 06 '13 10:03

JimH


People also ask

How do I clear a repository?

Steps to delete a GitHub repository Select the repository you wish to delete. Click on the Settings tab. Move down to the Danger Zone section page. Click the Delete this repository option.

What is git reset?

Summary. To review, git reset is a powerful command that is used to undo local changes to the state of a Git repo. Git reset operates on "The Three Trees of Git". These trees are the Commit History ( HEAD ), the Staging Index, and the Working Directory.

How do I re initialize a repository?

You can do this, and it will not affect your remote repos at all (you'd have to delete those seperately if that is what you want). delete on local, than checkout the repo again ;) @Thilo - exactly just remove the . git directory, run git init, remove all your remote repos and push again.


2 Answers

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

like image 179
JohnNY Avatar answered Oct 14 '22 00:10

JohnNY


Can backup – then delete the .git folder – and start fresh?

Yes. This is all there is to it.

Some really exotic set-ups might have the .git folder outside of the working directory; but otherwise the .git folder contains all the information there is wrt git. If you remove that, you remove all history, git-metadata and such.

If you had remotes, the link to them is lost, as that is stored in the same .git folder. The remote itself, on say your Gitlab server, is obviously not gone. So if you re-add that same remote on your clean environment it will cause history to re-appear, which might cause merge conflicts.

Edit: for those who might not have read the entire question: warning: this will remove all your git history.

like image 15
berkes Avatar answered Oct 13 '22 23:10

berkes