git config --global user.name "Andreas Mueller"
git config --global user.email "amueller@nyu.edu"
git config --global color.ui "auto"
git config --global core.editor "nano"
You can change these setting at any time. Show your configuration:
git config --list
git init
ls -a
git status
Check in with git
start tracking file
Record current state
-m
: commit message inlinegit status
git add filename
git commit -m "commit message"
git log
Open your mars.txt file and add:
The two moons may be a problem for Wolfman
Check the status of your files
git status
View the changes you made
git diff mars.txt
Tell git which files you want to record changes in
git add mars.txt
Save changes to revision history
git commit -m "concerns about Mars' moons"
Changes between working directory and what was last staged
git diff
Changes between staging area and last commit
git diff --staged
HEAD
HEAD~1
HEAD~2
git log
to get appropriate hashChanges made in the last commit
git diff HEAD~1
Changes made in the last 2 commits
git diff HEAD~2
Changes made since commit hash...
git diff 0b0d55e
git log
to find commit you wantecho 'The mummy will like the dry air.' > mars.txt
cat mars.txt
Recover last recorded version:
git checkout HEAD mars.txt
checkout HEAD
means revert to version in HEAD
mars.txt
: tells git which file to revertgit status
they list this option with --
instead of HEAD
. This is a shortcut.git checkout master