0

I currently have a system that goes like this:

Local Host: This houses the repo that I change and commit too.

Remote live host: This houses the master branch

I have a github webhook which trigger git pull once a change is commited and synced on local host.

When I setup the remote live host I did,

git init
git pull  https://github.com/myusername/myrepo.git

It cloned the repo but the permissions were all messed up. I changed all the permissions around and everything seemed to work great.

Then I made some changes to sidebar.php and synced with github.

When running git pull on the remote host I get:

From https://github.com/blablabla/repo
 * branch            HEAD       -> FETCH_HEAD
Updating d676e29..9cd0f26
error: Your local changes to 'sidebar.php' would be overwritten by merge.  Aborting.
Please, commit your changes or stash them before you can merge.

But there was never a remote change on the server. If i change my local sidebar.php back to the original before the commit, sync it and pull on the remote live host, It then says Up-To-Date

I have been battling with this thing for 3 days and can't seem to get it working correctly. I just want the remote live host to pull whatever is new from the repo since I did a syn from my local host.

Hydra IO
  • 1,537
  • 1
  • 13
  • 28
  • Did you try tout perform a pull request and commit à gain? – David Level Jul 17 '13 at 20:44
  • yes, any change that I commit and push to github from localhost when pulled will result in the "local changes" error on remote live. – Hydra IO Jul 17 '13 at 20:45
  • Are you by chance doing any `git push`s to the repo on your remote server? – Abe Voelker Jul 17 '13 at 20:50
  • @AbeVoelker the remote server should not be doing anything other then pull from the repo. FTP is turned off so the only way it can access its files is via `pull` – Hydra IO Jul 17 '13 at 20:54
  • Status shows `sidebar.php` has been changed but not commited, however this on my local server it has been committed and pushed to git. – Hydra IO Jul 17 '13 at 21:12
  • Ok did you try to git clone your repo inside an other directory, do your update and push? – David Level Jul 17 '13 at 21:14
  • Maybe you have a problem inside git log and that's why he can't do a fast forward normaly but I can't be sure of that without seeing your repo logs – David Level Jul 17 '13 at 21:16
  • I can clone the repo inside of another folder, and pull with no issue. The initial pull seems fine. The pull after a local commit and push seems to be my issue. – Hydra IO Jul 17 '13 at 21:17
  • Are you sure that nobody changed the file on github? I guess you have a public repo so people can edit files isn't it? Maybe a file was change but not commit on remote repository. You can check history on github I just saw that – David Level Jul 17 '13 at 21:20
  • To do it fine, you can check if there is difference between the file you just download while you did a git clone inside the new directory and the one online. Maybe they are different ones – David Level Jul 17 '13 at 21:23
  • The remote repository only has pull. The local repo syncs with github and is intact and correct. The files on the remote repo are not touched the only way they are updated is via pull – Hydra IO Jul 17 '13 at 21:23

2 Answers2

2

It seems like git changing file permissions is causing the issue. Try

git config core.filemode false

in the remote repo (see this question for more info).

Community
  • 1
  • 1
Abe Voelker
  • 30,124
  • 14
  • 81
  • 98
  • wow this fixed the initial problem of initial pull changing file perms thanks! but it sadly did not fix my issue with the secondary pull failing. – Hydra IO Jul 17 '13 at 21:25
  • Can you paste the output of `git diff`? I'm wondering if it is changing the line endings or something (e.g. if you are developing on a Windows box and doing pulls from a *nix box). – Abe Voelker Jul 17 '13 at 21:38
  • that is _exactly_ what I am doing. Dev on windows, production on CentOS – Hydra IO Jul 17 '13 at 22:11
  • In that case try doing `git config core.autocrlf false` in the remote repo. More info here: https://help.github.com/articles/dealing-with-line-endings – Abe Voelker Jul 17 '13 at 22:24
0

When you created the repo you didn't do all the stuff needed. I can't be sure of it because I use to create my own remote repo but maybe that will help.

Do:

git init
touch Readme.md
git add Readme.md
git commit -am "Initial commit"
git push

Then you clone and work on your local machine.

David Level
  • 353
  • 2
  • 16