Skip to content

Instantly share code, notes, and snippets.

@radiocontrolled
Created July 12, 2019 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radiocontrolled/417ffa23ad5e1427f234f7a4d6c35d1a to your computer and use it in GitHub Desktop.
Save radiocontrolled/417ffa23ad5e1427f234f7a4d6c35d1a to your computer and use it in GitHub Desktop.
GitHub in 5 minutes

Clone a repository
Cloning refers to making a copy of a repository (e.g. https://github.com/bbc/vjdata.24555.cqcfsa) to your local machine - so you can have access to the code on your own pc.
git clone git@github.com:bbc/vjdata.24555.cqcfsa.git

Initiate a repository from scratch
Requires an existing folder whose changes you want to track (called the 'working directory') This command will create a .git folder inside the directory, which is responsible tracking the changes your are making.

  • cd into the directory
  • git init

Check what files have been modified locally
git status

Create a branch to work on a new feature
git checkout -b <your-branch-name>

Add a single file to the stage
git add <filename>

Add all files to a the stage
git add .

Commit staged files
git commit -m <your-commit-message-goes-here>

Push the local branch you created to Github
git push origin <your-branch-name>

Push changes after remote branch has been created
git push

Merge a branch into your branch
git merge <branch name

Get latest details about branches
git fetch origin

I've made a mistake, and I want to overrite my local work with what's on master
git fetch origin git reset --hard origin/master

Resource: https://education.github.com/git-cheat-sheet-education.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment