TransWikia.com

Git: Stashed Changes But Still Can't Pull

Stack Overflow Asked by CrawfordBenjamin on November 29, 2021

I have looked all over and followed several different sets of instructions on this but none seems to work for me.

I have a GitHub repository and I have made some changes on my local machine and some on my Linux server and was hoping to merge the two.

In the past, I have used the git stash command and then been able to pull and then pop the stash to merge. I have never done this on Linux but I assumed it would the same as windows. However, even though I have stashed my changes on the server I am still unable to pull and receive this error:

error: Your local changes to the following files would be overwritten by merge:
aFolder/aDifferentFolder/aFile.py

So naturally I checked to see if my stash had gone through using git stash show and I got confirmation that the stash existed because the top line showed this:

aFolder/aDifferentFolder/aFile.py                 | 2110 +++++++++++++++++++++++++++++++++++++++----------------------------------------

This is very strange. But decided that I didn’t even want my changes on the server that much anyway so I decided to delete them using git reset --hard and then tried to pull and was met with the same error!

So in summary a list of things I have tried:
git stash
git reset --hard
git clean -f
git add . && git stash
git reset aFolder/aDifferentFolder/aFile.py

EDIT: Just to add more info here is the message I get upon calling stash:

Saved working directory and index state WIP on master: 1d49f3a Merge branch 'master' of https://github.com/username/repository
HEAD is now at 1d49f3a Merge branch 'master' of https://github.com/username/repository

One Answer

I never found out why this happened but a solution that worked for me was creating a new branch pushing to that and then merging with the master branch. Afterwards I deleted the useless branch.

Answered by CrawfordBenjamin on November 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP