【发布时间】:2020-03-26 22:53:32
【问题描述】:
我正在尝试按照 windows 上的本指南进行远程推送以部署到 windows 服务器上。
https://ma.ttias.be/simple-git-push-workflow-deploy-code-server/
-
从我笔记本电脑上的 git 服务器克隆 repo
-
向我的服务器添加了一个远程位置。
$ git remote add live \\\\hostname\\E\\myapp\\.git
git 配置如下所示:
[remote "live"]
url = \\\\hostname\\E\\myapp\\.git
fetch = +refs/heads/*:refs/remotes/live/*
- 在应用服务器上创建了一个裸仓库。使用 git bash
cd \e
mkdir myapp
mkdir .git
cd .git
git init --bare
git clone /e/.git /e/myapp
- 在 e:\myapp.git\hooks 文件夹中添加了 post-receive
#!/bin/sh
git --work-tree=E:\\myapp --git-dir=E:\\myapp\\.git checkout -f
git --work-tree=E:\\myapp --git-dir=E:\\myapp\\.git pull
echo "Hooray, the new version is published!"
exit 0
测试一:git push live master
Enumerating objects: 201, done.
Counting objects: 100% (201/201), done.
Delta compression using up to 4 threads
Compressing objects: 100% (198/198), done.
Writing objects: 100% (201/201), 86.90 KiB | 7.00 KiB/s, done.
Total 201 (delta 117), reused 0 (delta 0)
remote: Resolving deltas: 100% (117/117), done.
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
我运行了以下命令
git config receive.denyCurrentBranch updateInstead
测试 2:
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 281 bytes | 281.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To \\patlbearing02\E\bot-live\.git
! [remote rejected] master -> master (Working directory has staged changes)
我现在被困在这个问题上,不知道出了什么问题。我是 git 新手,我尝试了很多搜索,但还没有运气。
【问题讨论】: