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.

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.

0 reposts0 likes

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.

Takeaway: when you want a targeted update, treat it like a file-level import. Use git restore, keep main clean, and keep the change set small and auditable.