git patching via windows clipboard


Today I was fixing a bug in a hotfix branch during this I clean some code. At the end I don’t want push the cleanup to the hotfix. Instead of I want „move“ the changes into the develop branch.

I found that there is a /dev/clipboard available in git-bash on windows 🙂 So let’s define these two git alias:

alias.diffclip ! git diff > /dev/clipboard
alias.applyclip ! cat /dev/clipboard | git apply –

Now I can do a ‚git diffclip‘ in the hotfix repo folder, this will copy the remaining (unstaged changes) in my windows clipboard. In the other folder then I can do ‚git applyclip‘ and that’s it 🙂

Little update: today I found that my original redirect of git diff into clipboard doesn’t work (anymore) I have no glue why 🙂 But I found a working alternative:

git –no-pager diff | cat — > /dev/clipboard