Skip to content

Instantly share code, notes, and snippets.

@itsmattsoria
Forked from richardcornish/git.md
Created August 28, 2013 21:33
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 itsmattsoria/6371614 to your computer and use it in GitHub Desktop.
Save itsmattsoria/6371614 to your computer and use it in GitHub Desktop.
Enough Git for your résumé in fewer than 100 lines
==================================================
1. Install Git
http://git-scm.com/download/mac
(But consider using Homebrew)
2. Make a GitHub account
https://github.com/
3. Open Terminal
/Applications/Utilities/Terminal.app
Configure
=========
git config --global user.name "Your Name Here"
git config --global user.email "your_email@youremail.com"
Start a project
===============
mkdir -p ~/Desktop/totes-awesome-project/
cd ~/Desktop/totes-awesome-project/
git init
echo "# Totes Awesome Project" > README.md
git add . # Shortcut for adding all, which is just README.md
git commit -m "My first commit. So precious."
git remote add origin git@github.com:yourusername/Totes-Awesome-Project.git
# Create the new repository at https://github.com/new as "Totes Awesome Project"
git push -u origin master
# Go to https://github.com/yourusername/Totes-Awesome-Project
Work on a new feature
=====================
git checkout -b this-is-my-new-feature-branch # -b is shortcut for creating and switching to new branch
mate . # Textmate specific, so just work on something
git status
git add html9-boilerplate-framework-omg.css
git rm worthless.html
git commit -m "First edit for the feature"
# Work some more
git add whatever.min.js
git diff --staged
git commit -m "Second edit for the feature"
# You could push this-is-my-new-feature-branch out to remote if collaborating with others
# git push origin this-is-my-new-feature-branch
Update with new feature
=======================
git checkout master
git merge this-is-my-new-feature-branch
git push origin master
# Go to https://github.com/yourusername/Totes-Awesome-Project, get giddy
Delete new feature branch
=========================
git checkout master
git branch -d this-is-my-new-feature-branch
Stay updated with others
========================
cd totes-awesome-project
git pull origin master
git diff HEAD
Confused?
=========
git status # Show untracked/tracked files
git branch # Show branches and which one you're on
git log # Show the commits, or git log --graph for pretty
git show thelonggitlognumber1234567890 # Show old versions of files
git diff thelonggitlognumber1234567890 # Show diffs between file versions
Fork someone's work
===================
# Go to GitHub project, click Fork
git clone https://github.com/yourusername/cool-forked-project.git
cd cool-forked-project
git remote add upstream https://github.com/theotherguy/cool-forked-project.git
git fetch upstream
Benefits of Git:
- You have a local copy of the repository, which complements local development with `rails s`/`python manage.py runserver`
- Branching for new features is easier than SVN
- Faster/smaller in size than SVN
- Just remember to visualize the local/remote + branch/master way of thinking
Good links:
https://help.github.com/articles/create-a-repo
http://rogerdudler.github.com/git-guide/
http://hoth.entp.com/output/git_for_designers.html
http://gitimmersion.com/
http://csswizardry.com/2012/12/my-git-workflow-for-inuit-css/
http://mac.github.com/
http://git-scm.com/doc
https://delicious.com/richiesee/git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment