2018-8-10-git-push-错误-hook-declined-
| title | author | date | CreateTime | categories |
|---|---|---|---|---|
|
git push 错误 hook declined
|
lindexi
|
2018-08-10 19:16:52 +0800
|
2018-2-13 17:23:3 +0800
|
git
|
我把仓库上传到 gogs 出现错误,提示如下 remote: hooks/update: line 2: E:/gogs/gogs.exe: No such file or directory
gogs 仓库无法上传,一个原因是移动了gogs,如果把gogs放在移动U盘,插入时,上传经常出现这个问题。
在 push 的提示:
git push origin master
Counting objects: 32, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (32/32), 2.00 MiB | 0 bytes/s, done.
Total 32 (delta 19), reused 13 (delta 7)
remote: hooks/update: line 2: E:/gogs/gogs.exe: No such file or directory
remote: error: hook declined to update refs/heads/master
To http://127.0.0.1:3000/lindexi/gogs.git
! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'http://127.0.0.1:3000/lindexi/gogs.git'
那么如何解决。
可以看到是 hook 炸了,其中 update 文件出现找不到路径。
原因是我把 gogs 从E盘移动到D盘,于是 提交 gogs 仓库出现 remote: hooks/update: line 2: E:/gogs/gogs.exe: No such file or directory 。
解决方法:
打开 gogs 仓库 gogs ,注意我的gogs仓库之前所在是 E:\gogs\lindexi\gogs.git\ 所以我移动了路径但是里面的路径不会变,打开 update 文件。
可以看到:
#!/usr/bin/env bash
"E:/gogs/gogs.exe" update $1 $2 $3 --config='E:/gogs/custom/conf/app.ini'
于是我修改 E盘的路径到我现在使用的路径,就好了。
这问题是 update 钩子指向错误的路径。
简单的方法是:
进入控制板,重新生成所有仓库的 Update 钩子。这样就好了。
那么对于备份了 gogs 要恢复,需要如何做?
- 修改 custom/conf/app.ini
把 repository 路径修改现在的路径,同样修改日志
- 打开 gogs ,进入管理页面
重新生成所有仓库的 Update 钩子
如果对于 gogs 仓库在上传时出现的问题,可以去看gogs故障,也可以联系我:lindexi_gd@163.com
一般有时间我会去看看。
如果对于文章有疑问,欢迎交流。
我写了小程序,可以启动 gogs 判断他是不是移动路径,如果移动,就自动修改,程序很简单。
可以到 http://download.csdn.net/detail/lindexi_gd/9766835 下载。
可以把 gogs 放到任何地方,启动运行 启动.exe 运行可以关闭,gogs继续运行。
代码
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using IniParser;
using IniParser.Model; namespace gogs.gocer
{
class Program
{
/// <summary>
/// 自动迁移gogs
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
bool march = ReadCustomAppini();
if (march)
{
Restore();
} string str = System.AppDomain.CurrentDomain.BaseDirectory + "gogs.exe web";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
p.StartInfo.RedirectStandardError = true;//重定向标准错误输出
p.StartInfo.CreateNoWindow = true;//不显示程序窗口
p.Start();//启动程序 //向cmd窗口发送输入信息
p.StandardInput.WriteLine(str + "&exit"); p.StandardInput.AutoFlush = true;
//p.StandardInput.WriteLine("exit");
//向标准输入写入要执行的命令。这里使用&是批处理命令的符号,表示前面一个命令不管是否执行成功都执行后面(exit)命令,如果不执行exit命令,后面调用ReadToEnd()方法会假死
//同类的符号还有&&和||前者表示必须前一个命令执行成功才会执行后面的命令,后者表示必须前一个命令执行失败才会执行后面的命令 p.OutputDataReceived += (s, e) =>
{
Console.Write(e.Data + "\r\n");
}; p.ErrorDataReceived += (s, e) =>
{
Console.Write(e.Data + "\r\n");
}; //获取cmd窗口的输出信息 while (!p.HasExited)
{
Console.WriteLine(p.StandardOutput.ReadLine());
} string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();//等待程序执行完退出进程
p.Close();
Console.WriteLine(output);
} private static void Restore()
{
string file = System.AppDomain.CurrentDomain.BaseDirectory + "custom\\conf\\app.ini"; var ini = new FileIniDataParser();
IniData customAppini = ini.ReadFile(file); string gogs = System.AppDomain.CurrentDomain.BaseDirectory;
customAppini["repository"]["ROOT"] = gogs.Replace("\\", "/"); gogs = System.AppDomain.CurrentDomain.BaseDirectory + "log";
customAppini["log"]["ROOT_PATH"] = gogs.Replace("\\", "/"); using (StreamWriter stream = new StreamWriter(file))
{
ini.WriteData(stream, customAppini);
} RestoreUpdate(); } private static void RestoreUpdate()
{
var folder = new DirectoryInfo(System.AppDomain.CurrentDomain.BaseDirectory);
var gogs = System.AppDomain.CurrentDomain.BaseDirectory + "gogs.exe";
var gc = System.AppDomain.CurrentDomain.BaseDirectory + "custom\\conf\\app.ini";
gogs = gogs.Replace("\\", "/");
gc = gc.Replace("\\", "/");
foreach (var temp in folder.EnumerateDirectories("*git", SearchOption.AllDirectories))
{
try
{
var file = temp.FullName + "\\hooks" + "\\update"; string str = $"#!/usr/bin/env bash\n\"{gogs}\" update $1 $2 $3 --config='{gc}'"; using (StreamWriter stream = new StreamWriter(file))
{
stream.Write(str);
}
}
catch (Exception)
{ }
}
} private static bool ReadCustomAppini()
{
//当前路径 string file = System.AppDomain.CurrentDomain.BaseDirectory; //获取路径 if (!file.EndsWith("\\"))
{
file += "\\";
}
file += "custom\\conf\\app.ini";
if (!File.Exists(file))
{
return false;
}
var ini = new FileIniDataParser();
IniData customAppini = ini.ReadFile(file);
var gogs = customAppini["repository"]["ROOT"];
gogs = gogs.Replace("/", "\\");
if (!gogs.EndsWith("\\"))
{
gogs += "\\";
} return gogs != AppDomain.CurrentDomain.BaseDirectory;
}
}
}
2018-8-10-git-push-错误-hook-declined-的更多相关文章
- git remote: error: hook declined to update
提交一个项目,push的时候,报错: remote: error: File xxx.rar is MB; this exceeds Git@OSC's file size limit of 100 ...
- git push错误解决方案
错误提示: error: The requested URL returned error: 403 Forbidden while accessing https://nanfei9330@gith ...
- github多用户git push错误remote: Permission to user1/z.git denied to user2
背景:同一台电脑的public key同时添加到了github的两个账户,导致user1的仓库没法正常提交. 解决办法:为两个账户分别配置ssh key,配置~/.ssh/config文件(windo ...
- git push 错误,回滚 push操作
作者:故事我忘了¢个人微信公众号:程序猿的月光宝盒 0.记一次使用git push后,覆盖了同事代码的糗事 前言: 都在WebStorm中操作,Idea或者PyCharm同理 为了高度还原尴尬 ...
- Git push错误non-fast-forward后的冲突解决
当要push代码到git时,出现提示: error:failed to push some refs to ... Dealing with “non-fast-forward” errorsFrom ...
- git push错误,如何回滚
--> git push Counting objects: 81, done.Delta compression using up to 4 threads.Compressing objec ...
- git push解决办法: ! [remote rejected] master -> master (pre-receive hook declined)
前天准备上传一个project到GitLab上,但是试了很多次都上传不上去,报错如下: ! [remote rejected] master -> master (pre-receive hoo ...
- Git push时报错 ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to......
今天在使用Git回退到之前某个版本的代码时,进行push时出现如下错误: ! [remote rejected] master -> master (pre-receive hook decli ...
- Git push提示pre-receive hook declined
master:local auto@ubuntu:~/src/code/ git push Counting objects: 5, done. Delta compression using up ...
- To ssh://xxx.com:8022/test/project.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'ssh://xxx.com:8022/test/project.git'
To ssh://xxx.com:8022/test/project.git ! [remote rejected] master -> master (pre-receive hook dec ...
随机推荐
- Sass-注释
注释对于一名程序员来说,是极其重要,良好的注释能帮助自己或者别人阅读源码.在 Sass 中注释有两种方式,我暂且将其命名为: 1.类似 CSS 的注释方式,使用 ”/* ”开头,结属使用 ”*/ ”2 ...
- springboot中MongoDB的使用
转载参考:http://www.ityouknow.com/springboot/2017/05/08/spring-boot-mongodb.html MongoDB 是一个高性能,开源,无模式的文 ...
- MFC的Dlg和App什么区别?应用程序类与对话框类
MFC里有个app类..他是一个项目工程类,有一个全局的实例化.theApp你可以理解为整个项目的实例,它重载了入口函数,所有的窗口神马的,都是在这个类里实例化的. dlg是对话框,是一个窗口.一个程 ...
- BZOJ2280 [Poi2011]Plot 二分+倍增+最小圆覆盖
题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=2280 https://loj.ac/problem/2159 题解 显然对于一段的 \(q_i ...
- boost multi array
Boost MultiArray is a library that simplifies using arrays with multiple dimensions. 1. #include < ...
- boost unordered
Boost.Unordered provides the classes boost::unordered_set, boost::unordered_multiset, boost::unorder ...
- 如何通过Dataphin构建数据中台新增100万用户?
欢迎来到数据中台小讲堂!这一期我们来看看,作为阿里巴巴数据中台(OneData - OneModel.OneID.OneService)方法论的产品载体,Dataphin如何帮助传统零售企业实现数字化 ...
- HTTP的FormData和Payload的传输格式
FormData和Payload是浏览器传输给接口的两种格式,这两种方式浏览器是通过Content-Type来进行区分的(了解Content-Type),如果是 application/x-www-f ...
- 在使用KVO遇到的一个问题
在项目开发中定义了一个单例对象RHUserData的对象,RHOLUserInfo类是单例对象的一个property属性,RHOLUserInfo里面有个userId的属性,在其他类里面进行设置KVO ...
- (转)Docker 网络
转:https://www.cnblogs.com/allcloud/p/7150564.html 本系列文章将介绍 Docker的相关知识: (1)Docker 安装及基本用法 (2)Docker ...