0

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 root@ec2-54-197-239-43.compute-1.amazonaws.com:/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 ?

gturri
  • 13,807
  • 9
  • 40
  • 57
Rasika Vijay
  • 395
  • 1
  • 7
  • 17
  • If you only push to a server, no changes are made on the filesystem. In fact, only the index gets updated. Could you post the relevant part of a `git log --graph --pretty=format:'%h -%d %s'` on both servers? I think you just reverted your commit. – martin Jul 31 '14 at 07:13

1 Answers1

2

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.

Community
  • 1
  • 1
Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186