As it turns out, Git is smart enough not to drop a stash if it doesn’t apply cleanly. I was able to get to the desired state with the following steps:
- To unstage the merge conflicts:
git reset HEAD .
(note the trailing dot) - To save the conflicted merge (just in case):
git stash
- To return to master:
git checkout master
- To pull latest changes:
git fetch upstream; git merge upstream/master
- To correct my new branch:
git checkout new-branch; git rebase master
- To apply the correct stashed changes (now 2nd on the stack):
git stash apply stash@{1}
Related Posts:
- How to Git stash pop specific stash in 1.8.3?
- git stash apply version
- How do I ignore an error on ‘git pull’ about my local changes would be overwritten by merge?
- Stash only one file out of multiple files that have changed with Git?
- How do I ignore an error on ‘git pull’ about my local changes would be overwritten by merge?
- Stash only one file out of multiple files that have changed with Git?
- How can I git stash a specific file?
- How can I git stash a specific file?
- How do you stash an untracked file?
- How to name and retrieve a stash by name in git?
- How do you stash an untracked file?
- How to name and retrieve a stash by name in git?
- Stash just a single file
- Stash just a single file
- How do I ignore an error on ‘git pull’ about my local changes would be overwritten by merge?
- How to delete a stash created with git stash create?
- Git diff against a stash
- Move existing, uncommitted work to a new branch in Git
- Git stash pop- needs merge, unable to refresh index
- How to recover stashed uncommitted changes
- Difference between git stash pop and git stash apply
- What is git tag, How to create tags & How to checkout git remote tag(s)
- What is the best (and safest) way to merge a Git branch into master?
- Squash my last X commits together using Git
- How to apply a patch generated with git format-patch?
- Abort a Git Merge
- GitHub: Permission denied (publickey). fatal: Could not read from remote repository
- How to delete a remote tag?
- Updates were rejected because the tip of your current branch is behind its remote counterpart
- Updates were rejected because the tip of your current branch is behind its remote counterpart
- Git fetch remote branch
- Updating a local repository with changes from a GitHub repository
- How do I remove a submodule?
- Git push results in “Authentication Failed”
- What does “Changes not staged for commit” mean
- git: fatal: Could not read from remote repository
- How do I update Homebrew?
- Git error when trying to push — pre-receive hook declined
- Gitignore not working
- Could not open a connection to your authentication agent
- How to get just one file from another branch?
- git checkout a single file from another branch and put in different folder
- Update Git branches from master
- Create a branch in Git from another branch
- github website publish cannot publish unborn HEAD
- What is HEAD in Git?
- What are the differences between git remote prune, git prune, git fetch –prune, etc
- How to get the current branch name in Git?
- How do I resolve git saying “Commit your changes or stash them before you can merge”?
- Filename too long in Git for Windows
- Git – Ignore node_modules folder everywhere
- How do I provide a username and password when running “git clone [email protected]”?
- How to undo ‘git reset’?
- “*** Please tell me who you are.” when using SSH key
- master branch and ‘origin/master’ have diverged, how to ‘undiverge’ branches’?
- fatal: Not a valid object name: ‘master’
- Git and nasty “error: cannot lock existing info/refs fatal”
- How do I delete a local repository in git?
- Throw away local commits in Git
- Hard reset of a single file
- How to remove remote origin from a Git repository
- .gitignore and “The following untracked working tree files would be overwritten by checkout”
- Is there a “theirs” version of “git merge -s ours”?
- How to clone a specific Git tag
- How do I copy a version of a single file from one Git branch to another?
- Heroku: How to change a Git remote on Heroku
- Updates were rejected because the remote contains work that you do not have locally
- fatal: This operation must be run in a work tree
- Undoing a ‘git push’
- How to replace local branch with remote branch entirely in Git?
- What’s the significance of the “No newline at end of file” log?
- How to revert a “git rm -r .”?
- Git update submodules recursively
- Do a “git export” (like “svn export”)?
- What does git push origin HEAD mean?
- How do I set up Eclipse/EGit with GitHub?
- Repository size limits for GitHub.com
- How to clone git repository with specific revision/changeset?
- How to compare a local Git branch with its remote branch
- git push origin master does not work
- Found a swap file by the name
- Git clone verbose output?
- Could not create work tree dir ‘example.com’.: Permission denied
- Is there a git-merge –dry-run option?
- How to answer the git prompt in npm init for a local repo
- How to update Git clone
- Git says “Automatic merge failed”, what does it mean?
- Sourcetree adding files in global .gitignore, not in repository .gitignore
- How to configure git bash command line completion?
- How to stop tracking and ignore changes to a file in Git?
- Git Push Error: insufficient permission for adding an object to repository database
- Git push requires username and password
- WordPress and Git – What folders should I track?
- Pull latest stable release via git [closed]
- Why do the Roots theme CSS files not load (404)?
- Painless way to track remote Git repo for WordPress updates
- Questions about Git and WordPress [duplicate]
- WordPress on git – need help with configuration
- How to retrieve the last modification date of all files in a Git repository
- How do I edit git’s history to correct an incorrect email address/name [closed]