This error has no relation to the server, because the error occurs in a PULL ("pull") and not PUSH ("push"). This is the first clue in GIT that the problem is actually on your side.
The first step in verifying any problems with your local repository is to use git status
. This command will tell you all files that have changed and not yet committed in your local repository.
Should the command run git status
and any file appears as altered you may not be able to do a git pull
until the changes are undone or committed.
To add ALL local changes to the Stage and commit them use the commands git add .
and git commit -m "mensagem do commit"
.
To "undo" changes to a specific file you can use the command git checkout <arquivo>
.
To undo ALL local changes UNPINNED you can use the command git reset --hard HEAD
.
Please note that the last two commands are irreversible and any unmerited changes WILL BE LOST.
In the specific case of this message, most likely there have been changes to the remote repository and your local repository, you have made a git pull
previously generated a conflict and this was not resolved. The same message may still appear in other situations, but, by the described in the question, I would say that this is the most likely.
Anyway, the git status
will indicate which files are in trouble. Fix them and Comite them to be able to make a new git pull
.
For anyone curious about how to reproduce the problem:
Create a repository and commit with the file exemplo
mkdir repo
cd repo
git init
touch exemplo
git add exemplo
git commit -m "commit repo 1"
cd ..
Clones the previous repository and commits by changing the sample file.
git clone repo repo_clone
cd repo_clone
echo "alteração no repo_clone" >> exemplo
git add exemplo
git commit -m "commit clone 1"
cd ..
Go back to the original repository and commit a change to the sample file
cd repo
echo "alteração no repo" >> exemplo
git add exemplo
git commit -m "commit repo 2"
cd ..
Go back to the cloned repository and try to make a git pull
. Now the conflict will be presented.
cd repo_clone
git pull origin master
Ignore the error and go back to the original repository to make a new change.
cd ../repo
echo "nova alteração no repo" >> exemplo
git add exemplo
git commit -m "commit repo 3"
cd ..
Go back to the cloned repository and make a git pull
. At this time the question error message will be displayed.
cd repo_clone
git pull
To check the file conflict:
cat exemplo
Will be presented something like:
<<<<<<< HEAD
alteração no repo_clone
=======
alteração no repo
>>>>>>> (...)
And did you run git add to modified files? There are conflicts with another branch or with the remote, there’s no way we can tell.
– Guilherme Nascimento
the production server is only a clone of the "origin" repository. So I just pull into it because it has a few more files and directory that git shouldn’t track. So never.
– Cristian Benites
I didn’t say it’s done on the server side, you have file conflicts, probably due to another branch or something you did with some pullrequest or remote.
– Guilherme Nascimento