How to recover all files in folder from specific branch

How to recover all files in folder from specific branch

To recover all files in a folder from a specific branch to your current working tree, use the git checkout or git restore command, specifying the branch name and the path to the folder. 

Run this command from your terminal: 
git checkout <branch-name> -- <folder-path>
For a safer, modern alternative (available in Git 2.23+), you can use Git Restore Documentation
git restore --source=<branch-name> --staged --worktree -- <folder-path>
How It Works
  • <branch-name>: The name of the branch containing the files you want to recover.
  • <folder-path>: The relative path to the folder (e.g., src/components/).
  • The double dash (--): Tells Git to treat everything after it as a file or directory path, rather than a branch name.
  • Once the command is run, the files will be placed into your working directory, staged, and ready to be committed

Comments

Popular posts from this blog

30 маловідомих, але корисних команд Linux (repost)

15 поширених команд Linux (repost з ITEDU.center)