English 中文(简体)
怎样做 令人振奋的历史?
原标题:How does Git track history during a refactoring?

我清楚地理解,Gite如何能够支持档案移动:由于它使用档案库,很容易发现“附加”文件与“移走”一样。

我的问题是,是否令人振奋:考虑到 Java,一揽子声明的改动,因此档案内容与NOT相同。 在这种情况下,Gite如何确定“附加”的档案与“移走”的档案共享历史? 如果我只做了微小改动或类似的非决定性解决办法,它是否检查了“最相似的内容”?

问题回答

Git FAQ所述,它将根据回忆情况发现类似内容。

吉唐不得不与许多不同的工作流程进行互动,例如,一些变化可能来自派系,那里可能无法提供更名人的信息。 依靠明确改称的跟踪,不可能将两 trees树混为一谈,只有两.(create/delete)是一片(create/delete)的树木,而另一.是使用某种其他冷却。

在第二份说明中,重新命名的跟踪实际上只是追踪树木内容移动情况的一个特殊案例。 在某些情况下,你可能有兴趣询问何时添加职能或转移到另一个档案。 只有在需要时,才依靠重新整理这一信息的能力,因此,Gite的目的是提供更灵活的方式,追踪你的树木是如何变化的。

However, this does not mean that Git has no support for renames.
The diff machinery in Git has support for automatically detecting renames, this is turned on by the -M switch to the git-diff-* family of commands.
The rename detection machinery is used by git-log(1) and git-whatchanged(1), so for example, git log -M will give the commit history with rename information.
Git also supports a limited form of merging across renames.
The two tools for assigning blame, git-blame(1) and git-annotate(1) both use the automatic rename detection code to track renames.


<http://git-scm.com/docs/git-log” rel=“nofollow noreferer”>gitlog<<>>a>向您提供了一些有关这种回忆的详细信息:

-B[<n>][/<m>]

完全改写为删除和制造的鞋子。 这有两个目的:

  • It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number m controls this aspect of the -B option (defaults to 60%).
    -B/70% specifies that less than 30% of the original should remain in the result for git to consider it a total rewrite (i.e. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines).

  • When used with -M, a totally-rewritten file is also considered as the source of a rename (usually -M only considers a file that disappeared as the source of a rename), and the number n controls this aspect of the -B option (defaults to 50%).
    -B20% specifies that a change with addition and deletion compared to 20% or more of the file s size are eligible for being picked up as a possible source of a rename to another file.

-M[<n>]

If generating diffs, detect and report renames for each commit. For following files across renames while traversing history, see --follow.
If n is specified, it is a is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file s size).
For example, -M90% means git should consider a delete/add pair to be a rename if more than 90% of the file hasn t changed.


其他参考资料:


Note: With Git 2.18 (Q2 2018), git status should now show you renames (instead of delete/add files) when you move/rename files.
See "How to tell Git that it s the same directory, just a different name".





相关问题
bzr init-repo and multiple projects

I m having difficulties understanding bzr init-repo. I have 3 projects that I want to have in their own isolated repository, in subversion I would use svnadmin create three times to create them. Like ...

How suitable is a DVCS for the corporate environment?

I ve been using SVN for some time now, and am pretty happy with how it works (but I can t say I m an expert, and I haven t really done much with branches and merging). However an opportunity has ...

Renaming directories with the Fossil DVCS

Is it possible to rename directories with Fossil? I ve tried the obvious command: fossil mv oldname newname Fossil then informs me that it has done something: RENAME oldname newname However, ...

Distributed source control for VisualWorks Smalltalk

One of the annoying things about Smalltalk is that it (usually) requires its own VCS, due to the way that it manages its source code. Squeak and Gemstone (at least in its GLASS version) have a DVCS ...

Can I clone part of a Mercurial repository?

Is it possible to clone part of a Mercurial repository? Let s say the repository is quite large, or contains multiple projects, or multiple branches. Can I clone only part of the repository? E.g. in ...

How does git track source code moved between files?

Apparently, when you move a function from one source code file to another, the git revision log (for the new file) can show you where that code fragment was originally coming from (see for example the ...

热门标签