How to start a git repo

2020-07-23

Let's make a new project call "Creator Blog"

Create Git Repository

on the server where the main repo will live...

$ mkdir CreatorBlog.git
$ cd CreatorBlog.git/
$ ls
$ git --bare init
Initialized empty Git repository in /path/to/CreatorBlog.git/

Create Development Directory

git started (haha) on your local copy

$ mkdir CreatorBlog
$ cd CreatorBlog/
$ git init
Initialized empty Git repository in /path/to/CreatorBlog/.git/

make sure to set a branch name that is not master

$ git checkout -b main
Switched to a new branch 'main'

set up the basics

$ touch .gitignore
$ touch ReadMe.md

before initial commit, make sure your author information is set if this is a brand new development environment

$ git config --global user.name "username"
$ git config --global user.email "username@email.tld"

initial commit

$ git add .
$ git commit -m "commit 0"
[main (root-commit) 35cbe90] commit 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore 

Remember to add your ssh key to your authorized key file if you haven't already

Set the location of the main repo

$ git remote add origin user@server:/path/to/CreatorBlog.git

Push to main!

$ git push origin main
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 205 bytes | 205.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To localhost:/path/to/CreatorBlog.git
 * [new branch]      main -> main

Congrats, you did the thing!