为什么 `git pull` 在我的网络服务器上失败?
Why does `git pull` fail on my webserver?
我使用 git 来更改 os 站点的代码库。文件内部的更改和文件的删除是有效的,但是,当我将新文件或目录(不是空的)添加到 repo 时,它不会在本地拉到网络服务器,拉动时不会显示任何错误消息,但在检查该文件时,它不在那里。它在 bitbucket 存储库中在线显示。
试图删除本地 git 存储库并再次克隆它,这样我从源中获取了所有文件,但是在拉取新添加的文件时问题仍然存在。它显示好像它被拉了:
...
18bb8ac..c9c1e40 master -> origin/master
Updating 18bb8ac..c9c1e40
Fast-forward
config/plugins/test1.txt | 22 ++++++++++++++++++++++
config/plugins/testing.txt | 22 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
create mode 100644 config/plugins/test1.txt
create mode 100644 config/plugins/testing.txt
但是检查(ls -la config/plugins/
)时,新文件不存在。即使我尝试使用 sudo git pull
.
进行拉动
我很努力,但之后我无法让文件出现,除非我删除整个本地存储库并再次克隆它。没有硬重置,似乎没有任何帮助。
我检查了什么:
- 确保有问题的文件确实保存了更改。
- 确保文件不符合我在 .gitignore 和 .git/info/exclude
中的排除规则
- 确保不尝试添加空文件夹。 Git 不会跟踪 those.
我在网络服务器上对此 repo 的权限设置基于:
https://www.agix.com.au/git-a-walk-through-for-sysadmins/
原来是:
sudo chown apache:apache -R /var/www/html/sites/mysite
cd /var/www/html/sites/mysite
# File permissions, recursive
sudo find . -type f -exec chmod 0644 {} \;
# Dir permissions, recursive
sudo find . -type d -exec chmod 0755 {} \;
sudo setfacl -R -b -m user:root:rwx -m d:user:root:rwx -m group:developers:rwx -m d:group:developers:rwx -m group:apache:rx -m d:user:apache:rx /var/www/html/sites/mysite
我在开发者组的用户。
这是我在服务器上的 .git 目录。
我正在使用 CentOS7 和 git 2.16.3.
将文件拉到同一台服务器上的其他存储库工作正常,所以我完全删除了这个有问题的存储库的远程存储库和本地 .git 目录,并创建了一个新的远程存储库并将现有文件添加到其中。只有这样才能解决问题。
希望下次如果问题再次出现,我可以用更多线索更新这个答案,说明我对 repo 做了什么让它变得疯狂。
我使用 git 来更改 os 站点的代码库。文件内部的更改和文件的删除是有效的,但是,当我将新文件或目录(不是空的)添加到 repo 时,它不会在本地拉到网络服务器,拉动时不会显示任何错误消息,但在检查该文件时,它不在那里。它在 bitbucket 存储库中在线显示。
试图删除本地 git 存储库并再次克隆它,这样我从源中获取了所有文件,但是在拉取新添加的文件时问题仍然存在。它显示好像它被拉了:
...
18bb8ac..c9c1e40 master -> origin/master
Updating 18bb8ac..c9c1e40
Fast-forward
config/plugins/test1.txt | 22 ++++++++++++++++++++++
config/plugins/testing.txt | 22 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
create mode 100644 config/plugins/test1.txt
create mode 100644 config/plugins/testing.txt
但是检查(ls -la config/plugins/
)时,新文件不存在。即使我尝试使用 sudo git pull
.
我很努力,但之后我无法让文件出现,除非我删除整个本地存储库并再次克隆它。没有硬重置,似乎没有任何帮助。
我检查了什么:
- 确保有问题的文件确实保存了更改。
- 确保文件不符合我在 .gitignore 和 .git/info/exclude 中的排除规则
- 确保不尝试添加空文件夹。 Git 不会跟踪 those.
我在网络服务器上对此 repo 的权限设置基于: https://www.agix.com.au/git-a-walk-through-for-sysadmins/
原来是:
sudo chown apache:apache -R /var/www/html/sites/mysite
cd /var/www/html/sites/mysite
# File permissions, recursive
sudo find . -type f -exec chmod 0644 {} \;
# Dir permissions, recursive
sudo find . -type d -exec chmod 0755 {} \;
sudo setfacl -R -b -m user:root:rwx -m d:user:root:rwx -m group:developers:rwx -m d:group:developers:rwx -m group:apache:rx -m d:user:apache:rx /var/www/html/sites/mysite
我在开发者组的用户。
这是我在服务器上的 .git 目录。
我正在使用 CentOS7 和 git 2.16.3.
将文件拉到同一台服务器上的其他存储库工作正常,所以我完全删除了这个有问题的存储库的远程存储库和本地 .git 目录,并创建了一个新的远程存储库并将现有文件添加到其中。只有这样才能解决问题。
希望下次如果问题再次出现,我可以用更多线索更新这个答案,说明我对 repo 做了什么让它变得疯狂。