4. Git basics - file status lifecycle
$ git status
untracked unmodified modified staged
add the file
edit the file
stage the file
remove the file
commit
5. Git basics - staging and committing
Stage file and track untracked files
$ git add <file name | wildcard>
Remove and stage file removal
$ git rm <file name | wildcard>
Commit staged changes
$ git commit -m “<message>”
6. Git basics - staging and commiting
$ cat .gitignore
tmp/ # ignore all files in tmp dir
logs/*.log # all files in logs dir with .log
*.tmp # all files with .tmp ext
7. Git basics - staging and commiting
Show unstaged changes
$ git diff
Show staged changes
$ git diff --cached
8. Git basics - staging and commiting
Show all commits with authors, dates and
descriptions
$ git log
Show all commits with complete diff
$ git log -p
Show all commits with additions/deletions
stats
$ git log --stat
9. Git basics - undoing things
Change last commit
$ git commit --amend
Unstage changes in given file
$ git reset HEAD <file name>
Revert unstaged changes in given file
$ git checkout -- <file name>