Frage

Does git have any official syntax that can be inserted into commit messages to reference previous changesets? E.g.:

Oops. Adding files accidentally missed out from #7557bd82e2d0c7335319392b4bcb178ce0b9620f

Or does Git not bother defining these, and leaves that up to the tool that is used to display the messages (e.g. Github or Assembla)?

In which case, does anyone know if Assembla has any such syntax, hopefully to convert the reference into a link to that changeset? If GitHub has syntax for this then Assembla probably copied them...

War es hilfreich?

Lösung

In Git, there is no such thing as "previous commit". There is a previous commit at a given point, but after a merge, a new commit might come to the branch and be inserted between "current commit" and "previous commit".

However, Assembla can link to a specific commit in git changeset logs. If you know the exact sha or HEAD you want to link to, you can use Assembla's markup:

Here are some examples:

[[r:c27dbd5d84dfa9302c47a26196221c921c7d8c12|link to sha]]
[[r:c27dbd5d84dfa9302c47a26196221c921c7d8c12]]
[[url:www.assembla.com/code/<:space>/git/nodes/master|link to head]]

Here are those examples in action: https://www.assembla.com/code/bobo-titas/git/nodes/867b914329

More information about Assembla's linking can be found in the "create new wiki page" page.

Andere Tipps

There is no predefined markup to specify commit hashes.

Git commit hashes are just hexadecimal numbers, so I guess you just do regex matching of /\<[0-9a-fA-f]{4,40}\>/ (minimum 4 digits, maximum 40 digits). You could additionally check if the match is a valid Git object (git rev-parse --verify "$match").


Seems like GitHub does have a special syntax after all. To specify commits in other repositories use the format <<username>>/<<repo>>@<<commitHash>> (details can be found in the question Github commit message links). Although I would personally avoid direct cross-project commit references.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top