1

UPDATE: I confirmed that it was indeed file permissions that was causing this issue to occur. My host has suPHP installed for security reasons which causes a 500 error if I do not have proper permissions set (755 on folders, 644 on files).

Unfortunately, with those permissions, I am unable to push changes to the folder via git.

Trying to work with permissions so that I can still be secure while also being able to deploy with git.

======================================

Below is the original question:

======================================

I have a non-bare remote repository that I push changes to after working locally.

My local machine has Ubuntu 14 and my remote server has Cent OS. Both are using Git version 1.9.1.

I was able to push to the remote repository's Master branch due to the following:

git config receive.denyCurrentBranch ignore

The following saved in ".git/hooks/post-receive"

GIT_WORK_TREE=../ git checkout -f

And it is executable (chmod +x).

Recently, after attempting to do a "git push dev master", it appears that there are no issues because it will successfully push.

When I SSH into the remote repository and do a "git log", it shows my newest commit listed. However, when examining the files, the changes are not present.

When typing "git branch", I see that I am currently on the Master branch (typing "git checkout master" confirms that I was already on the master branch).

The only way for me to see the changes is to look in the git log for the most recent commit and then type "git checkout [commit ID] ."

Doing this makes the changes show up but my permissions change and I am forced to use a bash script to change the permissions to what is desired.

What can be done to prevent this issue from occurring?

AndrewMRiv
  • 155
  • 1
  • 11
  • Are you sure you committed to the correct branch? – Tim Biegeleisen Jul 27 '16 at 05:00
  • Hi @TimBiegeleisen. Thank you for your response. Yes, locally I typed "git checkout master" to ensure that I was on the master branch before committing. It reminded me that I was already on the Master branch. – AndrewMRiv Jul 27 '16 at 16:07

1 Answers1

0

Here are the discoveries I made:

1.) File permissions were the reason changes were not being successfully made after a "git push". I made changes to the file permissions (664 instead) rather than 644 and changes were able to be pushed.

2.) File permissions would change after a git push. I was trying to keep my index.php file at 644 to prevent a 500 error occurring on the server, but after any "git push" (regardless of if I edited the index.php file or not), it would automatically be changed to 664 permissions.

3.) Adding "umask 022" to my post-receive file fixed that problem I am now successfully able to push to my remote repository with the correct permissions retained.

The following answer helped me solve this: Git change default umask when update file

For those that do not understand umask, this article explained it to me well: http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html

Community
  • 1
  • 1
AndrewMRiv
  • 155
  • 1
  • 11