How to Set Up a New GitHub Repo From Your MacBook

Because the first time I used git, I started from my local MacBook, not knowing about git clone.

So, I thought someone else might do the same thing and this guide would help.

Initialise a Repository From Local MacBook (without git clone)Again, this is for the case where you already started a local git repo before you create a repo on GitHub ~ you do not use git clone.


Create a project folderMacBook-Pro:~ bobthedude$ mkdir projectdude2.

Initialise local git repoMacBook-Pro:~ bobthedude$ cd projectdudeMacBook-Pro:projectdude bobthedude$ git init3.

Add remote git repositoryAfter you initialise your local repo above, you remembered that you have not created a repo on GitHub, so you go to github.

com and created one called projectdude.

Grab the repo url and replace <remote_repo_url> below.

MacBook-Pro:projectdude bobthedude$ git remote add origin <remote_repo_url>Alternative – You can actually skip step 1, 2, 3 above if you have already created a repository on github.

com and do a git clone <remote_repo_url> instead.

After this, you can follow the below steps.


Create a new local branchBelow command will create a local branch named bob-first-branch.

You can replace it with whatever name you want for your local branch.

MacBook-Pro:projectdude bobthedude$ git checkout -b bob-first-branch5.

Start developing your projectYou can check whether you are on the right branch or not by executing below command.

MacBook-Pro:projectdude bobthedude$ git statusOn branch bob-first-branchNow, you can start adding files, codes, etc.

that you need for your project.


Add all files you want to commitYou can add multiple files and directories all in one go.

Separate them by an empty space.

Below examples would add the following:a directory named modules along with the contents in it2 files, which are app.

py and execute.

shMacBook-Pro:projectdude bobthedude$ git add modules/ app.

py execute.

shThen, commit them.

The flag -a indicates you want to commit all the files you added previously, where -m lets you add a commit message/ comment to describe what this commit is about.

MacBook-Pro:projectdude bobthedude$ git commit -am "initial commit"7.

Specify git credentialsTwo things to specify here:First is your GitHub‘s account email; the email you used to sign up on GitHub.

Second is your GitHub‘s user name; this is the name you display when you login to your GitHub.

MacBook-Pro:projectdude bobthedude$ git config –global user.

email "bobthedude@something.

com"MacBook-Pro:projectdude bobthedude$ git config –global user.

name "bobgit"8.

Push your local changes to remote branchThis command will create a remote branch on your remote repository so you can create a pull request and later (once happy), merge the branch to your master branch.

The -u flag here indicates you are pushing your local changes in a local branch called bob-first-branch upstream to origin (which you specify in step 3 above).

MacBook-Pro:projectdude bobthedude$ git push -u origin bob-first-branchThat’s it!.After this command is executed, there’ll be a link for you to click on that will take you to the page where you can create a pull request.

Happy git-ing.

????.. More details

Leave a Reply