Git - Part 3: Status and Log

Check git status

git status

Check git log

git log

One-line git log

git log --pretty=oneline

One-line git log with short hash id's

git log --oneline

Show the latest commit for current branch

git branch -v

Git - Part 2: Repositories

Create a repository

Initialize a new Git repository

git init

Add and Commit to a repository

Stage Single file

git add index.html

Stage Multiple files

git add index.html index2.html

Stage All (new, modified, deleted) files

git add -A

Stage All (new, modified, deleted) files

git add --all

Stage All (new, modified, deleted) files

git add .

Stage Modified and Deleted files only

git add -u

Stage New and Modified files only

git add --ignore-removal .

Commit to repository

git commit -m "This is commit message"


  1. Create a new file index.html and add some content
    touch index.html
  2. Add index.html to Git
    git add index.html
  3. Check git status (see: index.html is ready for commit)
    git status
  4. Open index.html and change some of the content
    vi index.html
  5. Check git status (see: previous index.html is still ready for commit; index.html is modified)
    git status
  6. Commit changes
    git commit -m "Initial commit"
  7. Check git status (see: index.html is still modified)
    git status
  8. Add index.html
    git add index.html
  9. Commit index.html
    git commit -m "Content is changed"
  10. Check git status (see: nothing to commit)
    git status
  11. Check git log (see: both commits)
    git log

Git - Part 1: Settings

Global configuration is stored in a file .gitconfig your root (cd ~) folder.

Set your name

git config --global = 'John Doe'

Set your e-mail

git config --global = ''

Set default editor, which will be used for commit messages, resolving conflicts, etc.

git config --global core.editor vi


git config --global core.editor notepad

Turn off a warning about LF replacement

git config --global core.autocrlf true