Entry

Git basics

Solution

# Add all changes to commit
git add .

# Check changes that will be committed
git status

# Commit with message
git commit -m "Changed index.js"

# Push/pull changes to/from repository
git push
git pull

# Store changes since last commit
git stash

# Restore stashed changes
git stash pop

# Reset your repository to the latest commit. WARNING: deletes files
git reset --hard HEAD

Installation instructions:

  1. Download Git from git-scm.com/downloads
  2. Run git config --global user.name "Your name" and git config --global user.email youremail@example.com (the e-mail should ideally match the one you use on Git(Hub/Lab/Tea)

Creating a new repository

# In the root directory of your code
git init

# That's it! Now create a new repository on Git(Hub/Lab/Tea), and get the clone/git url
git remote add origin https://github.com/Denperidge/cms-cheatsheet.git

Using an existing repository