Post

Needed one change from a feature branch, without dragging the whole branch into main? There is a clean Git move for that. Quick thread on copying a single file across branches, no merge required.

0 reposts0 likes

Scenario: you updated a file in a branch, but main only needs to update that one file. Merging the branch would pull unrelated commits, risk conflicts, and expand the review surface.

Git can restore a file from another branch directly into your working tree. No cherry-pick, no merge commit, no rebasing gymnastics.

Command: git restore --source branch_name -- file_path This replaces the file in your current branch with the version from the specified branch.

After running it, you still control what lands in main. Review the diff, run tests, then commit just that file change.