How do I enable ident $Id$
on files in a Git repository?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
You can do this by adding a pattern for which files you want this functionality followed by
ident
in the.gitattributes
file. This will replace $Id$ with $Id:<40-digit SHA>$ on checkout of the file. Notice though that it won't give you a revision number of the file as in CVS/SVN.Example:
Link to gitattributes(5) Manual Page
Git's ident does not do what $Id$ does in other versioning systems. As a kludge, use RCS along with git: RCS for individual file revisions and git to checkpoint the project as a whole. As I said, this is a kludge but it does kinda make sense (sometimes for some things).
Summary: The recommended way of embedding version information in a product is to use the build system for that; see below for details and alternate approaches.
In Git (and I think usually also in other VCS systems with atomic commits) there is no such thing like version of a single file.
Git does support on-demand expansion of
$Id:$
keyword, but:ident
attribute set (in '.gitattributes' file in tree, or in '.git/info/attributes' for local repository settings).$Id:<sha-1 of blob>$
). The reason for this choice is that Git does not touch files that have not changed during branch switching or rewinding; if '$Id:$' expanded to revision info it would require to update every version-controlled file e.g. when switching branches.Git supports quite a wide set of
$Format:...$
placeholders which expands to commit information (e.g.$Format:%H$
replaced by a commit hash) but:export-subst
attribute.The recommended way of embedding version information is to do it via the build system (in a build stage); see for example Git Makefile and GIT-VERSION-GEN script used by Makefile in the Git web interface for the git.git repository.
You can however (ab)use a clean/smudge filter driver (via
filter
attribute) to get CVS-like keyword expansion, expanding keywords on checkout, and cleaning them up on entering contents to the repository.