Simon's Git(Hub) Reference

Git and GitHub Commands that I use repeatedly. Despite this, I fail to remember them, so here they are for when I forget.

2018/05/12

Tools: Git Tags: Console Git Github


Create a new repo from existing files

Assuming you’ve already set up your ssh stuff

git init
git add .
git commit -m "first commit"
git remote add origin git@github.com:simonrolph/repo.git
git push -u origin master

Creating and pushing to a gh-pages branch

git branch gh-pages
git push -u origin gh-pages

Go to https://github.com/username/repo/settings/ and change gh-pages to master branch

Force pull

git fetch --all

Then, you have two options:

git reset --hard origin/master

OR If you are on some other branch:

git reset --hard origin/<branch_name>

Source

Force Push

Push local stuff and ovwerwrite remote

git push origin <your_branch_name> --force

for example for force pushing to gh-pages branch

git push origin gh-pages --force

Source


You can find me on Twitter, Youtube and GitHub.