Skip to content

Instantly share code, notes, and snippets.

@dfenjves

dfenjves/git_cheatsheet

Last active Jun 16, 2017
Embed
What would you like to do?
The Flatiron Git Cheatsheet
Git Cheat Sheet for Flatiron HS Summer Program
1. Once you've created a directory that you want to track, initialize git with `git init`. Make sure your directory contains a README.md file.
2. To set up your github.com directory:
a. Go to your profile on github.com.
b. Click on the + button on the top right of the page. Choose 'new repository'
c. Give your new repository the same name as your local project.
d. In your terminal, add the github repository as 'origin.' You should be able to copy this from the github page once you've save it: `git remote add origin git@github.com:dfenjves/repository-name.git`
3. Check the status of your project with `git status`
4. When you're working on a project and want to commit your code:
a. Use `git add` with the filename you want to to add to your 'holding station'
b. When you're ready to commit, `git commit -m "add a message about the changes you've made`
c. When you're ready to push to your repository on github.com: `git push origin [branch name]` (if it's the first time you do this, add the flag `-u` after `git push`)
5. To create and switch to a new branch use `git checkout -b [branch_name]`
6. To switch to an existing branch use `git checkout [branch_name]`
7. To merge a branch into master:
a. `git checkout master` to switch into your master branch
b. `git merge [other-branch]`
c. (optional) push to github using `git push`
8. To copy an existing repository to your computer:
a. Go to the repository page on github.com
b. Click on the fork button on the top right of the screen.
c. Copy the SSH clone link on the right side of the new page.
d. Navigate to the development folder in your terminal and type `git clone [copied_text]`
e. cd into the folder you downloaded on your computer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment