https://github.com/yasu-s/git-commit-id-output
GitのコミットIDを出力するシェルスクリプト
https://github.com/yasu-s/git-commit-id-output
bash bash-script git
Last synced: about 2 months ago
JSON representation
GitのコミットIDを出力するシェルスクリプト
- Host: GitHub
- URL: https://github.com/yasu-s/git-commit-id-output
- Owner: yasu-s
- License: mit
- Created: 2019-08-18T01:14:18.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-18T01:43:29.000Z (almost 7 years ago)
- Last Synced: 2025-02-09T17:13:05.713Z (over 1 year ago)
- Topics: bash, bash-script, git
- Language: Shell
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 概要
Gitで現在のブランチのコミットIDをファイルに出力するシェルスクリプトのサンプルです。
# 実行環境
* Bash
* Git
# サンプルソース
## ./output-text.sh
現在のブランチのコミットIDのみをテキストファイルに出力するサンプルです。
```shell
git log -n 1 --pretty=format:"%H" > dist/commit-id.txt
# c8f8ab484161c025f5b1e62135f3d067aa841791
```
## ./output-json.sh
現在のブランチのコミットIDをJSON形式のファイルに出力するサンプルです。
```shell
git log -n 1 --pretty=format:"{ \"commitId\": \"%H\" }" > dist/commit-id.json
# { "commitId": "c8f8ab484161c025f5b1e62135f3d067aa841791" }
```