Committing projects up to Github

ref –
ref –

Create the repo

Make sure you have created a repository on Github via
Enter a repository name, then check the box where it creates a readme file.
Click ok.


Then fork it locally, directions below are taken from the url here:


On GitHub, navigate to your fork of your repository.
Clone URL buttonIn the right sidebar of your fork’s repository page, click
to copy the clone URL for your fork.

Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).

Type git clone, and then paste the URL you copied in Step 2. It will look like this, with your GitHub username instead of YOUR-USERNAME:

Press Enter. Your local clone will be created and the output from your terminal will be something like this:

Rickys-MacBook-Pro:Desktop rickytsao$ git clone
Cloning into ‘face-recognizer’…
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
Checking connectivity… done

Clone a single branch

git clone –branch dev

Clone with username

List branches of the the repository

(double dash next to “heads”)
git ls-remote –heads

Change working branch :

Create the branch on your local machine and switch in this branch :

$ git checkout -b [name_of_your_new_branch]
Change working branch :

$ git checkout [name_of_your_new_branch]
Push the branch on github :

$ git push origin [name_of_your_new_branch]

Uploading Project

Then, you’ll see the project folder on your desktop. Copy your source files into the folder. And to upload it to Github you do:

note – The project url can be found on the repo page on the righthand side bar. It should have a little paste icon next to it. Its the HTTPS clone URL…you should be able to just copy and paste to the terminal window

If the system tell you that origin already exists, keep going with the instructions.

Make sure you are in the directory of the folder that Git created on your computer. Then within the folder (which should have a git file) you go:

Rickys-MacBook-Pro:holistic-element rickytsao$ git push -f origin master

It will then ask you for your username and password:

Username for ‘’: redmacdev1988
Password for ‘’:


Counting objects: 651, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (645/645), done.
Writing objects: 100% (650/650), 130.74 MiB | 1.45 MiB/s, done.
Total 650 (delta 19), reused 0 (delta 0)
0ddae45..a74a112 master -> master

If you want to remove files, delete the files in your directory.
Then in the same directory, go:

git commit -a -m “removed fluff”
git push origin master

Pulling (cloning) the project onto your machine

git clone

src refspec does not match any ERROR

If you try pushing to a certain branch and it gives you a src refspec error, it means you are not on that branch. You need to switch to that branch first, THEN, push to it.

git checkout -b Ricky_Tsao
Switched to a new branch Ricky_Tsao

git commit -a -m “cleaned up stuff”
git push origin Ricky_Tsao

Cloning Single Branch

git clone learned –single-branch option to limit cloning to a single branch;
tags that do not point into the history of the branch are not fetched.

git clone -b branch_name –single-branch (double dash in front of “single”)

Merge current local branch with remote

$ git stash
$ git pull origin release/1.0.1
// fix conflicts
// git add, git commit
$ git stash pop

// git add, git commit, git push

See the list of files that have changes between your local and remote

$ git status
On branch dev
Your branch is up-to-date with ‘origin/dev’.
Changes to be committed:
(use “git reset HEAD …” to unstage)

modified: Src/Project/Website/Code/global/css/product.css
modified: Src/Project/Website/Code/global/standalonesim.html


$ git stash save “—–”
$ git stash list
$ git stash apply stash@{0}

Delete local branch

$ git branch -d feature/login

Pushing new files onto your branch

$ git add .
$ git reset build/config (or whatever path to folder you want to exclude)
$ git commit -m “Add existing file”
$ git push -f origin Your_Branch