Git Handy Notes (Part 1)

Posted by Erika Tynn on April 07, 2020 · Updated on May 02, 2020 · 1 min read

Part 2: Git Handy Notes (Part 2)

Part 1: Git Handy Notes (Part 1)

How to Initialise a New Git Repo Before Commencing Coding

These are the bare minimum steps you need to take in order to initialise a brand new Git repo. You usually do this when you are about to begin a new coding project, and you want to set up a “blank” master branch and a “blank” dev branch before you write your codes.

You do this because you do not want your first commit to include code files, project files, and other stuff.

Initilises a new Git repository in the current directory

git init

(Optional) Specify Username and Email for Git commits

To specify your desired Username:

git config user.name [Desired Username]

To specify your desired Email:

git config user.email [Desired Email]

Tip

If you do not want to include an email, you can use this instead.

git config user.email "<>"

Creates an “empty” commit

git commit --allow-empty -m "Initial Creation"

Specifies remote repository, sets up master branch, then uploads to remote repository

git remote add origin [URL of remote repository]
git push -u origin master

Creates a new dev branch, then uploads this dev branch to remote repository

git checkout -b dev
git push -u origin dev