Skip to main content

Command Palette

Search for a command to run...

How to merge a specific directory or file in Git

Published
•1 min read
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

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 beginning

Streamlining Your Databricks Environment Setup

Guide to Efficiently Streamlining Your Databricks Environment Setup