Git Architecture: Local vs Remote

1. Local Repository

  • Stored on your machine
  • Includes:

    • Working Directory → your files
    • Staging Area → files ready to commit
    • .git folder → stores commit history and metadata
  • You can commit, branch, and revert without internet


2. Remote Repository

  • Stored on a server (GitHub, GitLab, Bitbucket)
  • Shared among multiple developers
  • Used for collaboration and backup
  • Common operations:

    • git push → send local change to remote
    • git fetch →bringing remote changes into local repo, but not merging them yet.
    • git pull → fetch + merge changes from remote

pull=fetch+merge


Summary

  • Local repo → your private workspace
  • Remote repo → shared team workspace
  • Git syncs local and remote via push, pull, and fetch