1/28/2012

How to start over in a Github repo

So I am cleaning up some source code and putting it onto Github. I made some mistakes when I made my first commit, so I needed to back that out. The rest of this short post describes how I did it.

But first, a warning: If other people are using the code in your repo already do not do this. It will completely mess them up and should only be done when you are first committing a project, or at least only when no one has forked the project.

First you scrap your commits in your local repo...

git init git add .

Next make sure there are no extraneous files...

git status

If there are files you don't mean to add the remove them...

git rm --cached FileToRemove

Next do the commit and force it onto the master...

git commit -a -m 'first commit' git remote add origin git@github.com:Owner/Repo.git git push origin +master

No comments: