From d8034c4ce1bd3ac05f529317f8858f00d2eb9acf Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 12 Jan 2021 11:32:41 -0600 Subject: [PATCH] Add Resolve A Merge Conflict From Stash Pop as a git til --- README.md | 3 ++- ...resolve-a-merge-conflict-from-stash-pop.md | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 git/resolve-a-merge-conflict-from-stash-pop.md diff --git a/README.md b/README.md index 3664f31..af992a0 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_1004 TILs and counting..._ +_1005 TILs and counting..._ --- @@ -258,6 +258,7 @@ _1004 TILs and counting..._ - [Rename A Remote](git/rename-a-remote.md) - [Renaming A Branch](git/renaming-a-branch.md) - [Resetting A Reset](git/resetting-a-reset.md) +- [Resolve A Merge Conflict From Stash Pop](git/resolve-a-merge-conflict-from-stash-pop.md) - [Show All Commits For A File Beyond Renaming](git/show-all-commits-for-a-file-beyond-renaming.md) - [Show Changes For Files That Match A Pattern](git/show-changes-for-files-that-match-a-pattern.md) - [Show Changes In The Compose Commit Message View](git/show-changes-in-the-compose-commit-message-view.md) diff --git a/git/resolve-a-merge-conflict-from-stash-pop.md b/git/resolve-a-merge-conflict-from-stash-pop.md new file mode 100644 index 0000000..ee39ebe --- /dev/null +++ b/git/resolve-a-merge-conflict-from-stash-pop.md @@ -0,0 +1,21 @@ +# Resolve A Merge Conflict From Stash Pop + +Occasionally when I've stashed some changes and then `stash pop` them back onto +me working tree, I'll end up with a merge conflict. Either some new commits or +other changes to the working tree are in conflict with what's in the stash. Git +tells me it's up to me to resolve it. + +Running `git status`, I can see what files have merge conflicts. I can go and +resolve those now based on what I want the state of my working tree to be. + +Running `git status`, I'll also note that the files from the stash not involved +in the conflict have been staged. I don' know why git stages those changes when +a merge conflict arises. When I `stash pop` and there is no merge conflict, git +leaves the changes on the working tree. + +This has confused me more than a couple times. Is there anything I need to do +to complete or resolve the `stash pop`? + +Nope. Resolving the conflicts in the affected files is all that needs to be +done. And since I'm generally not looking to create a commit at this point, I +_unstage_ the staged changes with `git reset HEAD`.