Git pull with unstaged changes

Posted by Peter on Server Fault See other posts from Server Fault or by Peter
Published on 2014-06-12T23:30:56Z Indexed on 2014/06/13 3:27 UTC
Read the original article Hit count: 308

Filed under:

Attempting a git pull when you have unstaged changes will fail, saying you can commit or stash then. I suppose a workaround is to git stash, git pull, then git stash pop. However, is there an alternative way to do this? I would like to forcefully git pull if there are unstaged changes, but only if the files being brought down do not override the modified files? AKA. if I have a repo with the files "derp1", "derp2", "derp3" and modify "derp1" locally, a git pull will bring down and overwrite everything except the "derp1" file.

I assume a git stash + pull + stash pop achieves this already? And is there a better way?

I suppose this could also work differently if it occurs on a submodule.

© Server Fault or respective owner

Related posts about git