Last Updated: September 29, 2021
·
509
· oschrenk

Merge upstream changes

Problem
I keep a fork of my personal dotfiles for my work environment. The personal dotfiles repo changes fairly often and I want to keep the work dotfiles up-to-date with upstream.

Solution
The work dotfiles are kept in their own repo, and the personal dotfiles repo is a remote and checked out as a branch.

Building on Jason Rudolph's Git Tip: How to "Merge" Specific Files from Another Branch I chose only to merge files and not cherry-pick changes.

Because the work repo does have some files the personal repo has not I (normally )only want to merge changed and added files

git checkout upstream $(git diff --name-status master..upstream | grep ^[MA] | awk '{ print $2 }' | tr '\n' ' ')

A final check that no work related configuration is lost

git diff --cached