- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我们有一个特定的要求,我们必须将所有到达的文件推送到某个分支。
我们计划通过 git hooks 特别是 commit-msg hook 来实现这一点。
这样做的同时,我们所做的是将分支克隆到临时位置 (/tmp/),然后在 git commit-msg Hook 中,尝试将到达的文件提交到某个分支。
但是现在发生的是我们看到/tmp/中的所有文件都已删除。
粗略的 commit-msg 脚本如下:-
#!/bin/bash
#
#!/usr/bin/env bash
#git config credential.helper store
REPOSRC="https://<USER>:<PASS>@<REPO_URL>"
LOCALREPO="<LOCAL_REPO_DIR>"
echo "Pulling code to temporarry location";
cd /tmp && git clone "${REPOSRC}" || (cd "${LOCALREPO}"; git pull;)
#here when I navigate to /tmp/<LOCALREPO> all files are listed as DELETED
git diff --cached --name-status | while read st file; do
echo "file == $file and status == $st";
if [ "$st" == "A" ]; then
cd "${LOCALREPO}" && git add "$file" && git commit "$file" -m "$COMMIT_MSG" && git push origin "$branch"
else
cd "${LOCALREPO}" && git commit "$file" -m "$COMMIT_MSG" && git push origin "$branch"
fi
done
这可能是什么根本原因?
编辑:
GIT_INDEX_FILE 显示发起提交 的索引文件路径,而不是/tmp/ 路径。有什么办法可以改变这个变量吗?索引文件也会打印类似 next-index-32419.lock 的内容。问候
最佳答案
每当 Hook 更改文件夹时,检查以下值很重要:
GIT_DIR
(在你的案例中应该引用正确的 .git repo 文件夹)GIT_WORK_TREE
(它应该不引用预期的文件夹)这就是为什么对于任何 Git 命令,您都需要将 git
替换为:
git --work-tree=$(pwd) ...
(或/path/to/your/working/tree
)
关于git clone git hooks 中的不同存储库造成麻烦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49249945/
什么是 vb6 或 java 中的对象克隆?我们在什么情况下使用克隆?克隆对象是什么意思?谁能用例子告诉我。 最佳答案 克隆实际上是将对象数据复制到新对象中。 此示例不克隆数据: Foo p = ne
ArrayList a=new ArrayList(); a.add(5); ArrayList b=(ArrayList)a.clone(); a.add(6); System.out.printl
这个问题在这里已经有了答案: Why does cloned() allow this function to compile (1 个回答) 关闭 3 个月前。 假设我们有一个可以克隆的某种类型的
我有这样的代码,我需要在其中将某些内容插入到两个单独的 HashMap 中。我只想要实现克隆的通用类型。 use std::collections::HashMap; use std::clone::
这段代码(also on play) use std::sync::Arc; struct Foo { x: isize, // Something complex in actual cod
我有按钮 Drag to insert h1 tag 当你拖动它时,我希望按钮留在原来的位置,助手是 Example在你放下它的地方,你会放下h1没有任何可拖动或 jQuery UI 样式的标记。 所
覆盖 clone 方法,而不实现 Cloneable 接口(interface)并且不调用 super.clone() 是一个好习惯。这样,就不会抛出 CloneNotSupportedExcepti
public abstract class Shape implements Cloneable { private String id; protected String type;
克隆远程仓库后,它不会通过 -a 选项显示任何远程分支。可能是什么问题呢?如何调试呢?在此片段中,未显示两个远程分支: $ git clone --depth 1 git://git.savannah
我看过这个答案for a git clone error ,建议不要克隆整个 repo,而是只克隆最新的提交,然后使用 unshallow 获取其余的提交。 考虑以下两个命令 1. git clone
当在网上搜索如何以多态方式深层复制对象的可能性时,我发现了 solution声称可以使用 clone() 方法解决许多问题,例如无法克隆 final 字段。该解决方案结合了在 clone() 实现中使
我正在尝试创建一个动态表单来向业务合作伙伴展示。 目标是能够在单击按钮时根据需要添加选择元素。但是,当它被点击时,它会复制模板两次,而不是一次。 这里只是我尝试过的代码的一些变体和 here is t
我知道实现 Object#clone() 的约定表明您应该调用 super.clone() 来获取复制的对象。 但我只是想知道如果我不这样做的话会有什么后果。让我们假设这个例子: class Some
我所说的示例:http://jsfiddle.net/bsnxp/1/ 如果你检查源 .show().clone() display 是 inline-block (它应该是什么)并且 .clone(
我正在编写代码来创建对象、克隆对象,然后比较两者。 所讨论的对象 Octagon 是对象 GeometricObject 的扩展 public class Octagon extends Geomet
我看到clone()在django代码中被广泛使用 queryset.query.clone() queryset.clone() 它的用途是什么?我应该模仿查询集或管理器方法中的行为吗? 最佳答案
我尝试导入 git project进入 eclipse 。手册告诉我在控制台中使用此命令: git clone http://git-wip-us.apache.org/repos/asf/mina-
我正在使用 jquery .clone(),它工作正常。但是我的问题是,当我克隆我的输入字段时,它也会克隆前一个字段的值。我不想克隆该值。我该如何克服这个问题? 这是我的代码 function add
在 this SO thread 中,结果表明,在制作项目副本方面,切片比任何方法都快。 使用: list1 = ['foo','bar'] copy1 = list1 * 1 list1.pop()
我有一个自动脚本可以解析服务器并克隆其中一个文件夹中的所有存储库。它所做的伪代码是: for each repo_name if a folder named like repo_name exi
我是一名优秀的程序员,十分优秀!