https://git-scm.com/book/en/v2/Getting-Started-Git-Basics
https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository#_git_basics_chapter
3 states: committed, modified, staged
Committed means that the data is safely stored in your local database. Modified means that you have changed the file but have not committed it to your database yet. Staged means that you have marked a modified file in its current version to go into your next commit snapshot.
This leads us to the three main sections of a Git project: the Git directory, the working directory, and the staging area.

The basic Git workflow goes something like this:
- You modify files in your working directory.
- You stage the files, adding snapshots of them to your staging area.
- You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
== install ==
windows: follow installation guide, download exe file
https://git-for-windows.github.io/
3 components: Git BASH – BASH emulation simiar with *NIX command line
Git GUI – graphic interface, Shell Integration – right click windows folder to access BASH and GUI
linux VB: whereis git, git –version
older version 1.7 already installed (suspect prev codes for protobuf etc required git)
most recent version is 2.1, how to update to 2.1???
== set up ==
//list all settings
$ git config --list
//get user name setting
$ git config user.name
//first time, set identity
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
help: $ git help {VERB}
== basic command to use ==
https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
$ echo “# helloworld” >> README.md //create a README.md file
$ git init //init, create .git repo file
$ git add README.md //add file to git
$ git commit -m “first commit” //commit with a msg
$ git add *.php
$ git commit -m “second commit”
at this moment, files are only versioned on local machine, not yet pushed to remote
//push to repository (created at github UI)
$ git remote add origin https://github.com/wangkun-buzzcity/helloworld.git
$ git push -u origin master
//pull to update local copy to recent from remote
//Do this before branching
$ git pull origin master
//use git fetch to update local repo (include all commits)
$ git fetch origin
//merge branch to master, under master do below
//after merging, do a push to update remote
$ git merge {branch name}
//merge master to branch is similar, under branch
//keeep a practice that do a final merge and testing to branch if master has new changes
$ git merge master
//check status, this will list all files status:
untracked: not yet in git tracking, use “git add”: to add in and then go to staged status
modified : file has local changes that not yet updated,use same “git add” to add modified files into staged
staged: ready for commit, Changes to be committed
unmodified: clean status
- every modify and change, needs to use “git add” to stage
$ git status
$ git status -s //short status: ?? untracked, A added to staging, M modified
$ git diff //to see waht you have changed but not yet staged
$ git diff –staged //to see what you’ve staged that will go into your next commit
//check commit history
$ git log
$ git log –oneline –decorate
$ git log –oneline –decorate –graph –all //history with graph
clone
//clone a project from git repository, helloworld reponame as directory
//clone is different from SVN checkout, clone includes all the history
$ git clone https://github.com/wangkun-buzzcity/helloworld.git
//close to a different folder name
$ git clone https://github.com/wangkun-buzzcity/helloworld.git helloworld2
//ignoring files, use .gitignore to track
$ cat .gitignore
*.[oa]
*~
remove files and move files
$ git rm {FILE} //stage the file’s removal. after commit, file will be deleted
undoing things
$ git commit –amend
== remote repository ==
$ git remote -v //show URL, origin is the default one