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 ...
随机推荐
- 关于javascript提交到java后台空格去不掉ASCII为160的解决办法
今天正则表达式匹配一个字符串,怎么都不对. 用正则表达式去掉尝试str.replaceAll("\\s*",""); 在或者用replaceAll(" ...
- 逗号导致hive报“SemanticException Error in parsing”错误
> select p.dt, p.cookie_qunar_global, p.refer_domain, p.kwid, p.query_word, p,traffic_type--, p.p ...
- Sass-@if的使用
@if 指令是一个 SassScript,它可以根据条件来处理样式块,如果条件为 true 返回一个样式块,反之 false 返回另一个样式块.在 Sass 中除了 @if 之,还可以配合 @else ...
- 2、pycharm中设置pytest为默认运行
1.打开File-setting 2.打开Tools-Python Integrated Tools 3.找到Default test runner选项,在下拉框中选择py.test 4.点Apply ...
- ubuntu下安装pyaudio
首先安装依赖库,不安装依赖库会安装失败: sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocp ...
- 使用DMA方式发送串口数据
一.初始化部分代码 //串口接收DMA缓存 uint8_t Uart_Rx[UART_RX_LEN] = {}; uint32_t Uart_Send_Buffer[] = {}; void USAR ...
- 二叉查找树BST
每棵子树头节点的值都比各自左子树上所有节点值要大,也都比各自右子树上所有节点值要小. 二叉查找树的中序遍历序列一定是从小到大排列的. 一个节点的后继节点是指,这个节点在中序遍历序列中的下一个节点.相应 ...
- BUUCTF | [SUCTF 2019]CheckIn
感觉这题师傅们已经写得很详细了,我就做一个思路梳理吧,顺道学一波.user.ini 步骤: 1.上传一个“.user.ini”文件 2.上传自己的马“a.jpg” 3.菜刀连接 "http: ...
- Jdk1.8 之 Integer类源码浅析
先看一下它的继承.实现关系: public final class Integer extends Number implements Comparable<Integer> Number ...
- oauth2学习
oauth2 生词: 授权码模式(authorization code) 简化模式(implicit) 密码模式(resource owner password credentials) 客户端模式( ...