是否可以从作为浅克隆的本地副本获取提交日志历史记录(--depth = 1)
我在 jenkins 构建作业中使用浅克隆来获取代码并构建,但更改日志不完整,因为我使用的是浅克隆。有办法解决这个问题吗?
我正在使用 Jenkins 文件来构建管道。我正在尝试使用如下 DSL 克隆参考存储库。
checkout(
[$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CloneOption', depth: 1, noTags: false, reference: '', shallow: true]],
submoduleCfg: [],
userRemoteConfigs: [[url: 'git@bitbucket.org:user_team/infrastructure-as-code.git']])
Run Code Online (Sandbox Code Playgroud)
当管道正在执行时,它正在被转换成这个
git fetch --tags --progress git@bitbucket.org:userteam/infrastructure-as-code.git +refs/heads/*:refs/remotes/origin/* --depth=1
Run Code Online (Sandbox Code Playgroud)
这会在我的 Jenkins 服务器上克隆整个存储库。我只想获得我的 repo 的浅拷贝,以便我可以从空间紧缩中拯救我的 Jenkins 服务器。请在这里帮忙。
我正在使用:Jenkins 版本:2.58,
插件:
流水线 SCM 步骤:2.4
吉特:3.3.0
如何将存储库的深层克隆就地转换为浅拷贝?
我正在使用 git 管理软件的单独安装,以跟踪安装运行时对代码的任何更改(未跟踪和脏文件),但存储库非常大(800MB),因此大约有数百个副本这不是最好的主意。
因此,如果这些存储库可以转换为仅包含当前部署的提交而不是完整树的浅表副本,那就太好了。在升级期间,存储库将被转换回深度克隆,检出特定提交,然后变成新提交的浅层克隆。
git fetch --depth=1 --update-shallow不会缩小 .git 目录大小,我猜它会获取任何新的提交,但不会删除旧数据。添加--shallow-exclude=HEAD^2会使 git 抛出错误,但不完全确定它应该如何工作,我会冒险猜测删除 HEAD^2 会产生冲突的要求,但想要检查 HEAD,这将取决于深度克隆中的 HEAD^2。
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud) 我想从项目中获取一些文件:我不需要克隆整个存储库:我只需要来自主分支的最新快照.这对我来说很重要,因为我的带宽非常低,下载所有内容需要一些时间.
在另一个问题上,我看到可以使用'git archive'这样做,不幸的是,似乎它不适用于https:
git archive --format=tar --remote=https://github.com/thomaspark/bootswatch.git master | tar tvf -
returns "fatal: Operation not supported by protocol."
Run Code Online (Sandbox Code Playgroud)
此命令与ssh://一起使用,但不与https://一起使用
对于github,我可以在Web界面上下载提供的zip文件,但对于其他没有提供它的存储库,如何从git存储库https URL获取简单快照?
我想在某个标签上创建一个 git 存储库的稀疏和浅层克隆。
这就是我目前正在做的事情:
git init avatica-tmp
cd avatica-tmp
git remote add origin https://github.com/apache/calcite-avatica/
git config core.sparsecheckout true
echo "core/src/main/protobuf/*" >> .git/info/sparse-checkout
git pull --depth=1 origin rel/avatica-1.10.0
Run Code Online (Sandbox Code Playgroud)
它工作正常,但抛出错误:
remote: Counting objects: 531, done.
remote: Compressing objects: 100% (381/381), done.
remote: Total 531 (delta 147), reused 280 (delta 51), pack-reused 0
Receiving objects: 100% (531/531), 963.03 KiB | 233.00 KiB/s, done.
Resolving deltas: 100% (147/147), done.
From https://github.com/apache/calcite-avatica
* tag rel/avatica-1.10.0 -> FETCH_HEAD
fatal: update_ref failed for ref 'HEAD': cannot update …Run Code Online (Sandbox Code Playgroud) 我有以下内容composer.json:
{
"require": {
"php": ">=5.2.0",
"queueit/KnownUser.V3.PHP": "dev-master"
},
"config": {
"autoloader-suffix": "ComposerManager",
"vendor-dir": "../../../all/libraries/composer"
},
"prefer-stable": true,
"repositories": [
{
"type": "package",
"package": {
"name": "queueit/KnownUser.V3.PHP",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/queueit/KnownUser.V3.PHP.git",
"reference": "master"
}
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行时:
$ composer -vvv update
...
Cloning master
Executing command (CWD): git clone --no-checkout 'https://github.com/queueit/KnownUser.V3.PHP.git' '.../sites/all/libraries/composer/queueit/KnownUser.V3.PHP' && cd '.../sites/all/libraries/composer/queueit/KnownUser.V3.PHP' && git remote add composer 'https://github.com/queueit/KnownUser.V3.PHP.git' && git fetch composer
Run Code Online (Sandbox Code Playgroud)
克隆过程需要很长时间,并且存储库的大小增长超过 25MB:
$ du -hs ~/.composer/cache/vcs/https---github.com-queueit-KnownUser.V3.PHP.git/
25M …Run Code Online (Sandbox Code Playgroud) 我有类Foo,它的成员bar_是指向某些数据的指针。方法modify修改数据,但不修改指针本身。因此我可以将该方法声明为const:
class Foo {
public:
Foo() : bar_(new double) {};
void modify() const {*bar_ += 1;};
private:
double *bar_;
};
Run Code Online (Sandbox Code Playgroud)
如果我将该方法声明为const,则可以从其他 const 方法访问它,这更加灵活。同时,我可以删除const作为其他开发人员和用户的提示,该方法间接修改数据(并认为数据归类所有)。所以我在这里有一个选择:声明modify为const或删除const :void modify() const或void modify().
每种方法的优缺点是什么?指导方针怎么说?我该怎么办?
我最初对git的理解是它(至少在最初阶段)是一个分散的VCS(允许例如完全脱机工作,甚至克隆来自另一个脱机存储库的repo ......).
根据我最初的理解,这仍然是检索存储库时术语"克隆"的原因:因为我们实际上正在获取它 - 它的完整副本(允许完整的脱机工作或其他人克隆它)更多等).
但后来我意识到事实并非如此:有时我正在研究我的主人,这是最新的; 然后切换到另一个分支,我希望它也是最新的,但是当我git fetch(或git pull)时,我会得到新的东西(不一定是新的).
那么我最初的理解错了吗?实际上是克隆而不是真正的克隆?它真的很浅吗?git clone的默认设置是什么?官方文档只说--depth"创建一个浅层克隆"; 我应该理解它能让我选择所述克隆的深度(或者我应该说浅薄?)?或者它创建了一个浅层克隆而不是一个没有选项的深层克隆?
git ×7
c++ ×1
clone ×1
composer-php ×1
constants ×1
git-archive ×1
git-clone ×1
git-log ×1
jenkins ×1