Rasika Vijay
Rasika Vijay

Reputation: 415

git repository is not reflecting the changes made even after git push

I have a git repository on a server (say gitserver) . I have cloned it to another server on the same farm (mysql server) . on the mysql server , I do a

    touch version.txt

add a few lines to it.

    git add version.txt
    git commit -am "added version text" .
    git push origin master 

output :

    git push origin master
    Counting objects: 5, done.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 309 bytes, done.
    Total 3 (delta 1), reused 0 (delta 0)
    remote: warning: updating the current branch
    To [email protected]:/opt/liveupdate/sqldb
    cb8ba55..ee4dab5  master -> master

On the liveupdate server , when I tried to see the file (version.txt) that I had added , I am unable to do so.

    git status 

gives me the following output .

    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       modified:   version.txt
    #
    # Changed but not updated:
    #   (use "git add/rm <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #       deleted:    version.txt
    #

And then on the gitserver I do a commit with the following output:

     git commit
     [master 4d8975a] adding version.txt
     1 files changed, 0 insertions(+), 2 deletions(-)

after all this , when I do a ls -a, shouldn't I be able to see that version.txt on gitserver ?

Upvotes: 0

Views: 4505

Answers (1)

Anshul Goyal
Anshul Goyal

Reputation: 76837

You are making a push to a non bare repo, on the checked out branch.

Ideally, you should have gotten an error - refusing to update checked out branch, but you seem to have already ignored the options using receive.denyCurrentBranch in your liveupdate server, and hence the files are appearing in the current state.

To avoid this, in your liveupdate server repo, do a git reset HEAD && git checkout . (and not a commit as you have already done - Check how to undo it)

Ideally, you should use an intermediate bare repo, so that you can push to the bare repo and pull from it later.

Upvotes: 2

Related Questions