4

I'm fairly new to Git and I'm struggling with an error.

I have a local copy of the code that is in prod, and made some changes (after a git pull). After making the local changes, I did:

git add . git commit -m git push 

Then I logged into the prod server, and ran git pull. I got the following error:

-> origin/master error: Your local changes to the following files would be overwritten by merge: Please, commit your changes or stash them before you can merge. error: The following untracked working tree files would be overwritten by merge: 

I'm not sure how it would affect my code if I stash the changes or made a commit. What should I do?

1 Answer 1

6

That error means that you have changes to your files on the prod server that are going to be clobbered by the git pull command that you are trying to run. Git decides that this is probably not what you want to do.

You could run git status to see what you have that isn't checked in/tracked on the prod server to see what you want to do with those changes. Then you have three options:

  1. git reset: those changes I don't need, get rid of them by resetting to the previous commit and then do the pull.
  2. git commit (adding relevant files first): those changes need to be in version control, check them in please. And then pull the latest changes over the top of those changes.
  3. git stash: those changes are a work in progress and I don't want to lose them, but I don't want to check them in yet either. You can retrieve them later.
Sign up to request clarification or add additional context in comments.

2 Comments

Awesome explanation for noobs like me
Is it possible to reset one particular file?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.