我对git很新,我面临以下问题。 我已经设置了远程服务器和本地服务器,我正在尝试将更改从本地服务器推送到远程服务器。 推送工作正常,没有任何错误,但从本地服务器推送的更改/文件在远程服务器中无处可见。
我缺少什么。?
编辑: 我遵循的步骤如下:
在远程服务器中,我在测试文件夹中初始化git,如下所示
git init --bare
在本地服务器中,在包含几个文件的测试文件夹中,我执行以下步骤
git init
git add .
git commit -m "test"
git add origin user@remote_server_ip:/path_to_test_git_folder/
git push origin master
在此之后,我收到以下消息,这使我相信推送成功
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 279 bytes | 279.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To 10.0.8.54:srv/git/test.git
97f4e97..30429fb HEAD -> master
但是本地服务器内的文件/更改不会显示在远程服务器上的任何位置。
答案 0 :(得分:2)
But the files/changes inside the local server does not show up anywhere on the remote server.
Which is expected, considering a bare repo does not have by definition a working tree.
You would need a post-receive hook in order to force a checkout somewhere on your server for the file to show up, as seen here.
/path/to/bare/repo.git/hooks/post-receive
#!/bin/bash
GIT_WORK_TREE=/path/to/workingtree git checkout -f -- .