git服務端問題解決 fatal: No remote repository specified. Please, specify either a URL or a remote name from which new revisions should be fetched.


=====

下面的解決辦法,可能只是適用於我遇到的這種情況,又想做鈎子,又想恢復原先老人們配置的git的正常使用。

=====

因為是以前離職的員工配的,所以先檢查一下原來的git能能正常使用不:

1、只有一條分支

master

 

2、版本庫和項目目錄是同一個,即

git clone root@www.xx.com:/home/project

生產服務器上的項目目錄也是: /home/project

=> 不知道 他們這么配的道理是什么。

 

3、在生產服務器上,執行 git pull,報告如下錯誤:

 fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched. 
=》百度上面的報錯,線上有很多同樣的解決方案,但可能不是我想要的。
且我在本地創建的文件1.txt和2.txt文件,在master上git add. , git commit -m "xx",git push,到了生產服務器上就變成:
使用git status查看狀態:
綠色的:
deleted 1.txt
deleted 2.txt 
=》這個是不正常的,我明明是提交了兩個新文件,但是生產服務器上是提示我要刪除掉這兩個文件。隱隱感覺,可能跟權限有關系。所以,我把項目文件夾權限改為777,再去git status就不會出現這種情況。

 

4、配置文件 .git/config

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
quotepath = false
[receive]
denyCurrentBranch = ignore

==========================================

 

解決方案:

1、給項目文件夾的提高權限

chmod -R 777 /home/project

 

2、修改 .git/config文件

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[receive]
denyCurrentBranch = ignore
denyNonFastForwards = false

 

3、進入.git/hooks/ 

=》git鈎子,百度有很多,但可能不適用我這邊的情況。

放入一個 文件,文件名: post-update

#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".

cd ..
env -i git reset --hard

=======================

結果:

 

我在本地提交,生產服務器上的項目文件夾里的文件目錄也起變化了,鈎子也成功。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM