Git: Cherry-Pick to working copy without commit

Git

Git Problem Overview


I have several branches where I keep certain commits that I want to apply to my working copy every now and then. Initially I tried cherry-picking but I do not want to have the commit in the target branch later.

So I did cherry-pick + reset HEAD~1 --soft

Is there something simpler like cherry-picking to working copy only?

Git Solutions


Solution 1 - Git

Use '-n' flag with the cherry-picking which is "no commit"

See here: http://git-scm.com/docs/git-cherry-pick

git cherry-pick -n <HASH>

To then unstage the staged changes

git reset

Solution 2 - Git

If you are using Terminal

git cherry-pick -n <HASH>

If you are using Intellij Idea

Settings -> Version Control -> git
untick commit automatically on cherry-pick 

Solution 3 - Git

For IntelliJ users

Settings > Version Control > Git: Uncheck Commit automatically on cherry-pick

enter image description here

Solution 4 - Git

You can also use apply instead of cherry-pick if you're just trying to apply all the changes you made in a commit to your working directory:

git show <commit> | git apply

This will apply the changes made in but will not add them to staging or create a commit.

Solution 5 - Git

I was getting errors that error: server/metadata/metadata-preui-prod.xml: No such file or directory

So now I do this

git checkout SHA -- server/metadata && git reset -- server/met adata

Old

git show SHA -- file1.txt file2.txt | git apply -

or all files from SHA

git show SHA | git apply -

https://stackoverflow.com/questions/5717026/how-to-git-cherry-pick-only-changes-to-certain-files/29788254#29788254

Solution 6 - Git

Simply run:

$ git cherry-pick --no-commit <HASH>

Solution 7 - Git

To solve this in Visual Studio 2019 without opening a console I went to the "Git Repository" window and right clicked on the Git Commit history and did a cherry pick on the commit I wanted. This commits the cherry pick. But then I did a right click on the commit below and did a "Reset -> Keep changes (--mixed)" which reset the commit but kept the changes uncommitted.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionschoetbiView Question on Stackoverflow
Solution 1 - GitIgal S.View Answer on Stackoverflow
Solution 2 - GitRavinda LakshanView Answer on Stackoverflow
Solution 3 - GitTrayan MomkovView Answer on Stackoverflow
Solution 4 - GitadamgyView Answer on Stackoverflow
Solution 5 - GitrofrolView Answer on Stackoverflow
Solution 6 - Gitmoriarty007View Answer on Stackoverflow
Solution 7 - GitJanspeedView Answer on Stackoverflow