KareemElashmawy
KareemElashmawy

Reputation: 251

Git push to bare repository not reflecting changes

On my local machine I have a dev branch and a prod branch of a master repository in bitbucket. This master repository is origin on my local remotes. I also have a webserver that's hosted as a bare repository to push changes to. This bare repository is prod-server on my local remotes.

When I push the contents of prod to prod-server master the production server tells me Everything up-to-date; but, if I check the webserver's files, their changed timestamp and contents do not reflect the changes in my commit!

Git-bash

[email protected] MINGW32 /c/git/ObfuscatedProjectName (prod)
$ git push prod-server prod:master -f
Password:
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 445 bytes | 445.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: fatal: This operation must be run in a work tree
To ssh://prodserver.com/ObfuscatedProjectName
   d24b1492..1898d38c  prod -> master

[email protected] MINGW32 /c/git/ObfuscatedProjectName (prod)
$ git push prod-server prod:master -f
Password:
Password:
Everything up-to-date

git log on server

commit 1898d38c67a1c35c30e002a4bc53b161973a944e
Author: Kareem Elashmawy <[email protected]>
Date:   Fri Sep 22 18:59:07 2017 -0400

    second commit today

commit d24b14928f3c0b950a2d1a09958bce3e6659386e
Author: Kareem Elashmawy <[email protected]>
Date:   Fri Sep 22 18:34:53 2017 -0400

    first commit today

commit e0de2b25d1cffb583f4a4b1fccbd88416ddac79f
Author: Kareem Elashmawy <[email protected]>
Date:   Thu Sep 21 18:02:51 2017 -0400

    yesterday's commit

ls -l on server

[kareem@domain python]$ ls -l
total 748
-rwxrwxr-x. 1 apache company    2126 Jul 21 15:36 file.py
-rwxrwxr-x. 1 kareem kareem  1733 Sep 21 17:18 file2.py
-rwxrwxr-x. 1 apache company    1461 Sep 21 17:44 file3.py
-rwxrwxr-x. 1 apache company   27257 Jul 21 15:36 file4.py
-rw-r--r--. 1 root   root   22597 Jul 25 11:50 file5.pyc
-rwxrwxr-x. 1 apache company    1458 Sep 21 18:08 file6.py

Notice the time stamps for files 3,4, and 5? They correspond to yesterday's commit, but were changed in today's 2 commits. If I open the files directly and check their contents, they are indeed unchanged since yesterday in spite of the git log specifying otherwise.

/ObfuscatedProjectName/hooks/post-receive

#!/bin/sh 
GIT_WORK_TREE=/home/ObfuscatedProjectName git checkout -f

Upvotes: 0

Views: 538

Answers (1)

KareemElashmawy
KareemElashmawy

Reputation: 251

A post-receive hook had been setup to checkout the repository upon receipt of commits. The directory url was wrong.

#!/bin/sh 
GIT_WORK_TREE=/home/ObfuscatedProjectName git checkout -f

/home/ObfuscatedProjectName should've been /ObfuscatedProjectName

Upvotes: 1

Related Questions