Copy file from another branch using Git

Every so often I find myself doing a search for finding the right command to copy a file from another branch to the current working branch in my Git workflows. It might be to go back to a working version if I messed it up, or to revert all my changes if I was working on something temporary.

git checkout <source-branch> -- <file-path>

where

<source-branch>: The name of the branch where the file currently exists.
<file-path>: The path to the file you want to copy (relative to the repository root).

This command will copy the file from the specified branch into your current branch’s working directory.

Example

Assuming we are on the main branch. And we want to copy a file src/config/settings.json from the branch feature-branch.

Run:

git checkout feature-branch -- src/config/settings.json

The file src/config/settings.json from feature-branch will now be in the working directory on main.

Year 2024 in Review

It's that time of the year for the year in review.

Quantum Computing

Being curious and always up for a challenge, I decided to seriously explore Quantum Computing this year. In this blog post, I recount my journey into the world of quantum computing, starting from my initial encounter with the concept back in 2005 to taking a course, reading up from articles and books as well as try out some practical projects using Q#.

Duplicate class StateUpdatedListener found

Over the last week I had spent a few evenings for what seemed like a 'minor' and routine library upgrade for my Android Apps. And I almost gave up.

Beyond Automation - Leveraging AI for Strategic Advantage

Integrating AI into business operations enhances growth, decision-making, and efficiency by fostering a data-driven strategy, improving marketing efforts, ensuring fairness, and innovating mobile app development.

The Plate Collector

A creative re-enactment of a real life incident that happened back in 2009 when I was attending a training with my colleagues. Since I am not creative enough to retell it in such a way to convey it across, it was natural to get some help, er.. all the help.

UX in Movies Part 1

Part 1 of a series exploring the effective use of UX interfaces in Movies, mainly Dashboards.

Year 2023 in Review

It's that time of the year for the year in review.

Technology UX in Movies

Have you ever wondered how technology interfaces in movies manage to captivate and guide us, regardless of our tech knowledge? I have had this idea for many number of years about combining two of my interests - movies and UX.

Updating Android Apps

I had been procrastinating with the update of my Android apps that were published to the Play Store for a few years now. It finally caught up to me as Google Play gave me a deadline of Aug 31, 2023 to update them to target the latest Android API version or be delisted from the store.