Last active
June 16, 2017 15:28
-
-
Save dfenjves/6c3832ae7c9d1cf504f2 to your computer and use it in GitHub Desktop.
The Flatiron Git Cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected]: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