Como devo usar a sintaxe do google git's ..

1

Gostaria de procurar a documentação da sintaxe .. do Git, que é usada, por exemplo, em um comando como git log master.. , que lista os commits em minha ramificação e não em master. Eu gostaria de saber como eles descrevem a documentação para que eu possa explicar de forma precisa e sucinta aos colegas.

Aqui estão as pesquisas que tentei

Os resultados são todos muito ruins. Existe uma maneira melhor de procurar documentação sobre o uso específico de linguagem da sintaxe de pontuação como .. ? Do Git?

    
por dumbledad 24.03.2016 / 10:19

1 resposta

2

Gostaria de procurar a documentação da sintaxe .. do Git

which is used, for example, in a command like git log master..

Eles são chamados de Double Dot .. e Triple Dot ... Especificações do intervalo.

Você também os vê referidos como Sintaxe do intervalo ou Sintaxe do ponto .

A pesquisa do link para qualquer um desses termos retornará resultados úteis.

Resumo breve

git log A..B (two dots)

While this syntax looks like a "range" of commits from A to B, it is actually a short hand for git log ^A B:

  • show all commits reachable from B; B itself is included
  • excluding those reachable from A; A itself is excluded

So given the following history (with the oldest commits on the left, the newest on the right):

*--*--*--A--*--*--*--B

git log A..B will show all the commits to the right of A.

Note that git log A.. is equivalent to git log A..HEAD.

git log A...B (three dots)

The git-rev-list man page describes this as a special notation for "symmetric difference".

It is equivalent to git log A B --not $(git merge-base --all A B).

In plain English, this means "all commits that are reachable from either A or B but not from both.

Fonte Sintaxe Git "range" ou "dot"

Resumo detalhado

Double Dot

The most common range specification is the double-dot syntax. This basically asks Git to resolve a range of commits that are reachable from one commit but aren’t reachable from another. For example, say you have a commit history that looks like:

enter image description here

You want to see what is in your experiment branch that hasn’t yet been merged into your master branch. You can ask Git to show you a log of just those commits with master..experiment – that means “all commits reachable by experiment that aren’t reachable by master.” For the sake of brevity and clarity in these examples, I’ll use the letters of the commit objects from the diagram in place of the actual log output in the order that they would display:

$ git log master..experiment
D
C

If, on the other hand, you want to see the opposite – all commits in master that aren’t in experiment – you can reverse the branch names. experiment..master shows you everything in master not reachable from experiment:

$ git log experiment..master
F
E

This is useful if you want to keep the experiment branch up to date and preview what you’re about to merge in. Another very frequent use of this syntax is to see what you’re about to push to a remote:

$ git log origin/master..HEAD

This command shows you any commits in your current branch that aren’t in the master branch on your origin remote. If you run a git push and your current branch is tracking origin/master, the commits listed by git log origin/master..HEAD are the commits that will be transferred to the server. You can also leave off one side of the syntax to have Git assume HEAD. For example, you can get the same results as in the previous example by typing git log origin/master.. – Git substitutes HEAD if one side is missing.

Multiple Points

The double-dot syntax is useful as a shorthand; but perhaps you want to specify more than two branches to indicate your revision, such as seeing what commits are in any of several branches that aren’t in the branch you’re currently on. Git allows you to do this by using either the ^ character or --not before any reference from which you don’t want to see reachable commits. Thus these three commands are equivalent:

$ git log refA..refB
$ git log ^refA refB
$ git log refB --not refA

This is nice because with this syntax you can specify more than two references in your query, which you cannot do with the double-dot syntax. For instance, if you want to see all commits that are reachable from refA or refB but not from refC, you can type one of these:

$ git log refA refB ^refC
$ git log refA refB --not refC

This makes for a very powerful revision query system that should help you figure out what is in your branches.

Triple Dot

The last major range-selection syntax is the triple-dot syntax, which specifies all the commits that are reachable by either of two references but not by both of them. Look back at the example commit history in:

enter image description here

If you want to see what is in master or experiment but not any common references, you can run

$ git log master...experiment
F
E
D
C

Again, this gives you normal log output but shows you only the commit information for those four commits, appearing in the traditional commit date ordering.

A common switch to use with the log command in this case is --left-right, which shows you which side of the range each commit is in. This helps make the data more useful:

$ git log --left-right master...experiment
< F
< E
> D
> C

With these tools, you can much more easily let Git know what commit or commits you want to inspect.

Fonte Git Tools - Seleção de Revisão

    
por 24.03.2016 / 12:04