Git Notes:

default

 
git init
# Initialize a repository in the current folder
# This creats a .git folder that stores traking data for the repository
# If you delete the .git folder, it will turn back to a normal files structure

git config --global user.name "Your name"
git config --global user.email "yourEmail@addy.com"
# Configure git to know who you are; author name and email
# SHA-1 checksums use this info when commiting
# Leave out --gloabl to set info for current repo only

git status
# Show status of a repo

git add somefile.txt anotherfile.txt
# Stage a file to be tracked by a repo 
# Stages a snapshot of the file

git .
# Add all new files to be staged

git commit
# Commit changes to repo 
# Commits the snapshot
# Witout -m it will prompt for info about the commit

git commit -m 'some info message about the commit'
# Commit with an inline message of what the commit is

git commit -a -m 'Added bug fix 022'
# Commit and stage at the same time with -a; must be tracked
# Works on all files that are already added that have changed

git log
# Displays history of the repo

git log --oneline
# Show commit history;  short description, on one line

git log --online thisFile.html
# Show history of one file; short description

.gitignore
# Create a file to have git ignore files that you don't want added to a repo
# *.log
# This would ignore all files ending in .log 

git branch someBranch
# Create a new branch of a repo

git checkout someBranch
# Switch to a branch of a repo

git checkout 08b67cf
# Go back to a previous snapshot
# Will put all your files the way they were during that snapshot
# Use git checkout master to get back to current state of project

git checkout master
# Switch back to the master branch

git tag -a v1.0 -m "Stable version of project"
# Tag a snapshot to be used instead of random hash

git tag
# List tags

git revert 5223179
# Revert a snapshot, undoing its changes

git merge someBranch
# Merge someBranch into the master (do this in master)

git mergetool
# Use merge tool to fix conflicts; else do it by hand
# Must have a merge tool installed

git stash
# Stash changes that you don't want to add yet

git stash apply
# Go back to stashed files when ready to work with them again

git remote
# List existing remote repos

default