Git Topics (9)Tap to view
    Git·Version Control·Topic 2 of 9

    Git Staging & Commits

    Daily work cycle, staging, checking status and variances of modifications.

    1. Most used commands

    1. git status

      What it doesDisplays the status of the Working Tree, Staging Area, and modified files

      When to use itBefore each commit or after modifications

      Examplegit status

    2. git status -s

      What it doesDisplays the status of files in a compressed, compact format

      When to use itWhen editing a large number of files and preferring a quick list

      Examplegit status -s

    3. git diff

      What it doesDisplays unprocessed changes (between Working Tree and Staging Area)

      When to use itto review modifications before git add

      Examplegit diff

    4. git diff --cached

      What it doesOnly displays ready-to-commit changes in the Staging Area ready to commit

      When to use itto review what will actually go into the next commit

      Examplegit diff --cached

    5. git add <file>

      What it doesPrepare a selected file to the Staging Area

      When to use itto prepare a specific file precisely and avoid making all the changes at once

      Examplegit add src/index.ts

    6. git add .

      What it doesPrepare all changes to the current path and subfolders

      When to use itto process all review edits at once

      Examplegit add .

    7. git add -p

      What it doesAn interactive installation that allows reviewing and selecting specific parts (Hunks) of the file

      When to use itWhen there are multiple edits in a file and you want to split them over multiple commits

      Examplegit add -p src/app.js

    8. git commit -m "msg"

      What it doesRecords a new Snapshot of changes equipped with a clear message

      When to use itAfter completion of a standalone logical feature or modification

      Examplegit commit -m "feat: add user authentication"

    Offline · Reading cached copy