March 19, 2025

Git checkout and restore commands

Photo Credit: Dall-E by OpenAI

Git Checkout Commit & Git Restore Branch

When working with Git, you might need to restore files/folders from a branch or a commit. Here’s how to do it efficiently.

πŸ”„ Using git restore (Git 2.23+)

For restoring files/folders from a specific branch without switching branches:

git restore --source=<branch-name> -- <file/folder-path>

Example:

git restore --source=develop -- src/config.json

This brings config.json from develop into the current branch without switching branches.

πŸ”„ Using git checkout (Git 2.23-)

For restoring files/folders from a specific branch without switching branches:

git checkout <commitSHA> -- <file/folder-path>

Example:

git checkout <commitSHA> --source=develop -- src/config.json

Peace... πŸ€

Tech Innovation Hub
Modern Software Architecture

Exploring cutting-edge technologies and architectural patterns that drive innovation in software development.

Projects

Β© 2025 Tech Innovation Hub. Built with Gatsby and modern web technologies.