0

The plan is to publish a site on the hosting server from a Git repository that I created on my local machine.

I created a Git repository in my server:

git init

Then I added a remote in my local to be able to upload the site:

git remote add origin ssh:com1@*************/home/com1/public_html/aum-crm/aum-crm.git

And I was able to push the site using git push origin master. The problem is that after the site got pushed, I have to go to the server and do two steps.

 Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   some/files/got_here.php
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)

I then do this:

git reset HEAD .

which results in this:

Unstaged changes after reset:
M        some/files/got_here.php

Finally I do git checkout --, and then the server will have the files.

If I tried to commit on the server instead of these step, but then it reverts which means it cancels all the files that got submitted from the local. :(

Why do I need to do these two steps? Isn't it supposed to just push the files to the server and they have to go there right away?

4

1 回答 1

0
*****@******.info [~]# 
*****@******.info [~/git]# mkdir test.git
*****@******.info [~/git]# cd test.git
*****@******.info [~/git/test.git]# pwd
/home1/******/git/test.git
*****@******.info [~/git/test.git]# git init --bare
Initialized empty Git repository in /home1/*******/git/test.git/
*****@******.info [~/www/test.git]# cd hooks
*****@******.info [~/www/test.git]# vi post-receive

接收后文件:

#!/bin/sh
GIT_WORK_TREE=/home1/*******/test git checkout -f

使用 :x 保存文件

*****@******.info [~/www/test.git/hooks]# chmod +x post-receive
*****@******.info [~/www/test.git/hooks]# cd ~
*****@******.infoo [~]# git init test
Initialized empty Git repository in /home1/*******/test/.git/
*****@******.info [~]# exit

这样,它将使服务器自动执行这些步骤。

感谢Erik Nidwidek

链接到他的答案

于 2013-10-23T22:37:03.323 回答