$ cd ~/.ssh
# if ~/.ssh doesn’t exist:
$ mkdir ~/.ssh
$ cd ~/.ssh
$ ssh-keygen -t rsa -C put_your_email_here
# use the email you use for your Github account
# Ignore the returned passphrase message,
# or set it to something simple and memberable (e.g. your computer password).
# When typing it, nothing will show. That’s normal.
$ pbcopy < ~/.ssh/id_rsa.pub
# copies your key to your clipboard
- Log in to github
- In the top right corner of the page, click on the gear icon
- On the profile page, under the
Personal Settings
menu on the left side of the page, clickSSH Keys
- Click
Add SSH Key
- Give the key a title
- Paste (
cmd + v
) your key from the command line into the text input box - Click
Add Key
and enter your password if needed
$ ssh -T [email protected]
# enter your password
If you don't have errors then Github is now fully operational on your machine!
$ git config --global user.name put_your_github_username
# sets your github username on your computer
$ git config --global user.email put_your_github_email
# sets your github email on your computer
$ git init # initializes repository in current directory
$ git add <file name> # stages (adds) changes for specified file
$ git add . # stages (adds) changes from the whole project
$ git status # tells what is currently staged and untracked
$ git commit -am “Initial commit”
# makes a git commit (snapshot)
# -am is a shortcut to add and commit ALL files
$ git commit -m “Description of the changes made”
# makes a commit of the current version of the file
$ git rm # unstages/removes file from git
$ git log # gives a history of our commits with their IDs
$ q # quits the git log screen
$ git remote -v # lists remote versions
$ git log --oneline # gives a simpler version of git log
$ git config list # lists your settings
$ git config --global user.name “your name” # sets your name
$ git config --global user.email “your email” # sets your email
$ git reset <filename>
# unstages file changes (HEAD refers to our last commit on current branch)
$ git checkout <filename>
# remove the changes
$ git reset --soft <commit ID>
# reverts back after changes that have been committed.
# --soft will keep these changes.
$ git reset --hard <commit ID>
# reverts back after changes have been committed.
# --hard will destroy these changes.
- On github, click on the
+
in the top right corner - Click
New Repository
- Give your repo a name--usually hyphen-delimited
- Choose public (or pay to create a private repo)
- Click to add a README if you want--it gets desplayed as the content on the webpage for your repo
- We can now return to our terminal and create a the repository on our local machine:
$ git remote add origin <SSH address>
$ git push -u origin master # -u tells github that the remote branch has the same name as our local branch. next time, we can just use git push
- If we now return to github and see the page for our repository, all the files which we have just committed and pushed should show.
$ git branch <branch name> # create a new branch
$ git checkout <branch name> # move to this branch
$ git checkout -b <branch name> # create and move to a branch
$ git checkout master # move to the master branch
$ git push origin <branch name> # push branch up to github.com
$ git merge <branch name> # merge <branch name> branch onto your current branch (or onto master, if you’re on master).