Ramesh Pareek
Ramesh Pareek

Reputation: 1669

Git Why changes do not reflect on remote repository?

I am trying to setup push to deploy on a vps (a digitalocean droplet), for this I created a repo and initiated it with --bare

  cd /var
    mkdir demorepo && cd demorepo
    mkdir demo.git && cd demo.git
    git init --bare

Now, created a hook named post-receive in hooks directory in the repo

#!/bin/sh
git --work-tree=/var/www/demo --git-dir =/var/demorepo/demo.git checkout -f

set permissions using

 chmod +x post-receive

On my local machine I created a new repo with git init in a folder\www\demo.git and added the remote repo as live

git remote add live ssh://[email protected]/var/demorepo/demo.git

The Problem Now I created a new file in the local repo and pushed it using

git push live master

The push is successful, But the changes don't reflect on the remote repo. what am I doing wrong?

Upvotes: 0

Views: 94

Answers (1)

Lasse V. Karlsen
Lasse V. Karlsen

Reputation: 391336

To ensure hooks work properly you should "debug" them by executing the commands manually.

If/when you get them working manually then you can think about putting them into a hook script.

In this specific question I would expect the command to fail with this error message:

fatal: Not a git repository: '=/var/demorepo/demo.git'

The reason for this is that you've unintentionally added a space after the --git-dir parameter.

git --work-tree=/var/www/demo --git-dir =/var/demorepo/demo.git checkout -f
                                       ^
                                       |
                                       +-- here

Remove that space and you should be good to go.

You could also remove the equal sign as the following two variants are the same:

--git-dir=x
--git-dir x

But you can't combine the two as in your case the equal sign is part of the path that git tries to locate, hence the error.

Upvotes: 1

Related Questions