Skip to main content

How to merge a specific directory or file in Git

Published 1 min readMarkdown
Part of seriesExpress Ideas
How to merge a specific directory or file in Git

Think of the following scenarios:

  • There might be two branches with active development and one of the branch needs some specific (updated) file or directory.
  • You don't want to merge the complete branch but just need some specific file(s).

Similarly, there might be 'n' no. of scenarios where the common theme is that instead of merging the complete branch, all you need to do is merges specific file(s)/directory(s).

Using a smart trick which I like to call 'Selective checkout' can do the intended job

git checkout destination
git checkout source sub-directory/
git commit -am "Message."
git pull --rebase
git push

Using this git terminal trick now you can actually perform specific file/directory merge without merging the complete branch.

2.8K views

No comments yet. Be the first to comment.

Express Ideas

Part 5 of 5

Small & self-contained tips that can help in many larger context. This is my attempt to help you out & shed some light on express ideas that helped me because it's just an idea that all you need 馃挕.

Start from the beginningStreamlining Your Databricks Environment SetupGuide to Efficiently Streamlining Your Databricks Environment Setup