This is usually due to a merge conflict. Most cases it is because more than one person modified the file at the same time or you are still in the process of merging. You can check out this older answer on this topic if you are still having issues. In terms of what you can do to avoid this problem:
If you're the only one working on this project (with this git repo) then make sure you pull the most recent version before you start working.
Be sure to check the status of your files using git status before you make a new commit. This should tell you if you have any unmerged paths.
After this you can take a look at any conflict markers (if they exist) and choose what you want to do next. You can reference this link if you need any more help with these steps. Personally, my flow of commands typically goes:
git status
git add examplefile
git commit -m "Merge message"
Then if everything looks good I'll push to my desired branch for example:
git push -u origin master
Lastly, if you need any more information on conflict markers this answer should hopefully be useful for you! Hopefully this helps, Git can be super confusing but its a super useful tool to have so once you get it down it's amazing!