复制Git裸回购是否会更改日志? [英] Does copying the Git bare repo change the log?
问题描述
我想用git尝试一些事情,而且我不想在工作库中搞砸.
I'd like to try out a few things with git and I don't want to screw anything up in the working repository.
为了保持安全,我已经复制了我工作的裸仓库,并打算从此仓库进行所有推送和标记.我用过:
To try to keep things safe, I've made a copy of the bare repo that I work from and from this repo I am intending to do all my pushes and tagging. I used:
cp --preseve -r original.git copy_of_original.git
尽管我知道一个人可以撤消错误的提交,但我不想将所有这些还原的提交留给仓库,也不想进行任何重构,因此我希望只在一个重复的裸仓库中工作
Although I understand one can undo bad commits and whatnot, I don't want to leave the repo with all these reverted commits, nor do I want to do any refactoring, hence my desire to just work from a duplicate, bare repository.
问题是,我执行以下操作:
The problem is, I execute the following:
git diff --name-only master@{"5 day ago"} master
然后回来:
warning: Log for 'master' only goes back to Fri, 15 Feb 2013 20:42:43 -0500.
我不想接触的原始回购确实确实包含了5天前已修改的文件.
The original repo, which I don't want to touch, does indeed have files which were modified as of 5 days ago.
如果我对复制的仓库执行git log
,则这5天的更改记录仍然存在.
If I perform git log
on my copied repo, the record of these 5 day old changes are all still there.
这是怎么回事?
是否有更好的方法来制作存储库的独立副本?
Is there a better way to make an independent copy of the repository?
更新1
我意识到自己对这个问题不甚精确.我跑了:
I realized I was imprecise with my question. I had run:
git diff --name-only master@{"5 day ago"}
在以下位置产生的目录中:
in the directory produced from:
git clone copy_of_original.git clone_of_copy
推荐答案
@{5 days ago}
语法依赖于 git-rev-parse的部分中进行了解释文档在下面引用.
Reflog对存储库而言是本地的,从不通过克隆,获取或
推.这不是git log
显示的信息,除非-g
或
使用--walk-reflogs
选项.
The @{5 days ago}
syntax relies on information from the reflog, as
explained in the section of the git-rev-parse documentation quoted below.
Reflogs are local to a repository, and never transferred by clone, fetch or
push. This is not the information displayed by git log
, unless the -g
or
--walk-reflogs
option is used.
裸仓库通常不保留reflog,因此仓库的副本 也不会有该信息.
Bare repositories generally don't keep reflogs, so a copy of the repository wouldn't have that information either.
<refname>@{<date>}, e.g. master@{yesterday}, HEAD@{5 minutes ago}
A ref followed by the suffix @ with a date specification enclosed in a brace pair
(e.g. {yesterday}, {1 month 2 weeks 3 days 1 hour 1 second ago} or {1979-02-26
18:30:00}) specifies the value of the ref at a prior point in time. This suffix may
only be used immediately following a ref name and the ref must have an existing log
($GIT_DIR/logs/<ref>). Note that this looks up the state of your local ref at a
given time; e.g., what was in your local master branch last week. If you want to
look at commits made during certain times, see --since and --until.
这篇关于复制Git裸回购是否会更改日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!