0

So, I have a developer who has a bitbucket account, and he updates the code into the bitbucket server and as I have access to the Linux server I pull the files via git pull. Now whenever I do that I get the following error:-

error: Your local changes to the following files would be overwritten by merge: 8.php Please, commit your changes or stash them before you can merge. Aborting

The interesting thing is I don't have any local copy in my system, I just log into the server and pull the code which the developer has updated. Whenever I try to do git -status it does show some unstaged files. How should I solve the issue, and can anyone let me know why is this happening?

Nitish Patra
  • 289
  • 5
  • 20
  • This shouldn't _keep_ happening, assuming you resolved the issue once, pulled, and then were in a position to pull again. Off the top of my head, it could be that there is some line ending issue which is causing some files to appear changed when in fact they are really not. What is the OS used by your dev team? We know you are on a Linux server, because you told us this much. – Tim Biegeleisen Jul 08 '18 at 14:16
  • 3
    Possible duplicate of [How do I resolve git saying "Commit your changes or stash them before you can merge"?](https://stackoverflow.com/questions/15745045/how-do-i-resolve-git-saying-commit-your-changes-or-stash-them-before-you-can-me) – Rafael Jul 08 '18 at 14:17
  • @Rafael I agree, but I think the real issue is why this message is showing up when in fact it probably should not be. – Tim Biegeleisen Jul 08 '18 at 14:32
  • @TimBiegeleisen I might be wrong, but the OP says that he does pull (i.e a local copy exist on the system) and when he do git status there are unstaged files? – Rafael Jul 08 '18 at 14:35
  • No...I'm suggesting that the OP believes he is in a state where his working directory is clean, and hence he should not be seeing this message. Just a hunch. – Tim Biegeleisen Jul 08 '18 at 14:35
  • But I think he is not in a clean working directory since there are usntaged files when he `git status`? I think that someone did some changes to the Linux server and there are unstaged. – Rafael Jul 08 '18 at 14:39
  • @TimBiegeleisen The developer is using Mac Os – Nitish Patra Jul 08 '18 at 14:43
  • @Rafael I do the pull but not into my local, i do it directly into the server directory by logging in with ssh – Nitish Patra Jul 08 '18 at 14:44
  • If you run `git status` in the ssh session do you still see unstaged files? – Rafael Jul 08 '18 at 14:48
  • @Rafael Yes, Just now I did another git pull, and again it showed unstaged file. Therefore I had to do git reset --hard and then git pull. The only operation I have done on this is git pull apart from that no commits nothing from my side, the other dev commits into the bitbucket server from his own account. Plus whenever I pull the files, the permission reverts back to 664 and I have to change it manually to 775 – Nitish Patra Jul 08 '18 at 14:56
  • Unless you are really sure about this, I am suggesting to stash those changes, and carry on. – Rafael Jul 08 '18 at 15:00
  • I cant really understand your problem, If you don't have any local copy in your system, you can't just do git pull right??? You have to clone the repository first... – Chathura Buddhika Jul 08 '18 at 15:05
  • Maybe git is looking out on a user basis, as I am not the owner of the files, but I am the admin though, or do i need to checkout before pull, dunno git is behaving wierd for me – Nitish Patra Jul 08 '18 at 15:05
  • @ChathuraBuddhika As i have mentioned above i am not executing the pull from my local computer, i am logging into ssh (putty) , getting into the project directory and then doing a git pull. – Nitish Patra Jul 08 '18 at 15:06
  • @Rafael could you please unmark it as duplicate, as the issue is quite bizarre, it might be useful for me to get other people's views on it – Nitish Patra Jul 08 '18 at 15:09
  • Flagging questions as a duplicate do not stop people from answering straight away. It is up to the moderators to close the question or not. However, I think your issue is really simple. You have some changes on your ssh server that are not staged or committed, you need to either commit them (if they are relevant), discard them (if they are irrelevant), or stage them (if you are unsure) then you are good to go. See the options in the above link. – Rafael Jul 08 '18 at 15:12
  • However, maybe someone is working on that server. Git is supposed to work distributed. So you should have a copy on your system so you don't mess up with other people. – Rafael Jul 08 '18 at 15:13
  • did you check what these changes actually are? Are that changes only line endings (`cr+lf` vs. `lf`)? – Timothy Truckle Jul 08 '18 at 15:22
  • 1
    @NitishPatra That means you have a local git repository in your server. In there obviously you have some local changes. That's why it shows merge conflicts. – Chathura Buddhika Jul 08 '18 at 15:25
  • Thanks, everyone. I will look into the issue. – Nitish Patra Jul 09 '18 at 05:50

0 Answers0