Brice Stacey home

Initialize Local Git Repository

I am starting a new coding project, but I always have trouble remembering how to configure my initial Git repository. Most of the tutorials online assume you want to create a git repository out of a working directory. Since I am starting this project from scratch, I don't particularly like to do this. I prefer to create a bare repository to be the master copy, clone it in some working directory, and push any commits back to the master. Conceptually, this process is most congruent with what is going on in my mind. First, I build the box, then I fill it.

First, create the Git repository:

mkdir ~/git/ezpc.git
cd ~/git/ezpc.git
git init --bare .

Then, clone it to a working directory:

mkdir ~/projects/ezpc
cd ~/projects/ezpc
git clone ~/git/ezpc.git/ .

Configure which repository you will push and pull to:

git remote rm origin
git remote add origin ~/git/ezpc.git
git push origin master

Then you can make your commits and just type git push.