Git
NOTE
[ ] means that it can be omitted.
Setup
git config --global user.name "my name"
git config --global user.email "my-address@goes.here"
git config --global core.editor "notepad++"
git config --list
git config --global -e # to use specific editor
cat ~/.gitconfig
4 Areas
- Working Directory
- Staging Area
- Repository (.git folder)
- Remote
Basics
Words
HEAD
means last commit.
Add
git add . # all files under current directory
git add -A # all files
git add -u # all files except new files (u = update)
git add . --dry-run # pre test
Commit
git commit -m "commit message"
git commit -am "commit message" # add & commit at same time
List tracked files
git ls-files
Unstage
git reset [HEAD]
git reset [HEAD] somefile.txt
Discard changes
git checkout [--] somefile.txt
Move files
git mv file1.txt file2.txt