Skip to content

Instantly share code, notes, and snippets.

@bleeckerj
Forked from jclay/git_cheatsheet.md
Created October 7, 2013 19:20
Show Gist options
  • Save bleeckerj/6873401 to your computer and use it in GitHub Desktop.
Save bleeckerj/6873401 to your computer and use it in GitHub Desktop.

Set username
git config --global user.name "Your Name Here"

Set e-mail
git config --global user.email "[email protected]"

Clorize and make git output pretty
git config --global color.ui true

Creating a repository
git init

Create a file

touch README.md
echo "Hello World" > README.md

Git status
git status
The file README.md we added above will show as untracked

Git add
Let's add our README.md to staging area
git add README.md

Git commit
Commit what we have in staging area to repository
git commit -m "Adding a README"

Git add remote origin
Add a remote so that we can sync our local repository
git remote add origin https://github.com/username/Hello-World.git

Create a new branch
git branch readme_update

Checkout (switch) to new branch
git checkout readme_update

A shortcut!
Create readme_update branch & checkout
git checkout -b readme_update

What branch are we on?
git status

Make some changes to readme

Add to staging area
git add README.md

Git status
Do our changes to README show up in staging area?
git status

Git commit
git commit -m "Committing changes to readme"

Switch back to master
git checkout master

Merge our changes from readme_update branch in
git merge readme_update

Delete readme_update branch
git branch -d readme_update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment