The command finds the most recent tag that is reachable from a commit. If the tag points to the commit, then only the tag is shown. Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object and the abbreviated object name of the most recent commit. The result is a “human-readable” object name which can also be used to identify the commit to other git commands.
By default (without –all or –tags) git describe only shows annotated tags. For more information about creating annotated tags see the -a and -s options to git-tag(1).
Stackoverflow 上一个去掉特定 hash 之前的 commit 历史的脚本,实测成功!-2019/12/26
#!/bin/bash
git checkout --orphan temp $1 # create a new branch without parent history
git commit -m "Truncated history" # create a first commit on this branch
git rebase --onto temp $1 master # now rebase the part of master branch that we want to keep onto this branch
git branch -D temp # delete the temp branch
# The following 2 commands are optional - they keep your git repo in good shape.
git prune --progress # delete all the objects w/o references
git gc --aggressive # aggressively collect garbage; may take a lot of time on large repos
查看修改过的代码: $ git status -uno –porcelain $ git diff --name-only <starting SHA> HEAD
来自: https://git-scm.com/book/en/v2/Git-Basics-Tagging
为 git 加版本号:
$ git tag -a v1.4 -m "my version 1.4"
带 tag push 代码
$ git push origin branchname --follow-tags
查看标签指定的版本:
$ git show v1.4
为某个指定的提交后续添加版本标签:
$ git tag -a v1.2 9fceb02
提交代码:
1. git commit -a -m "msg"
2. git tag v0.1.0
3. git push origin tag v0.1.0
-v, –verbose be more verbose
-q, –quiet be more quiet
–all fetch from all remotes
-a, –append append to .git/FETCH_HEAD instead of overwriting
–upload-pack <path> path to upload pack on remote end
-f, –force force overwrite of local branch
-m, –multiple fetch from multiple remotes
-t, –tags fetch all tags and associated objects -n do not fetch all tags (–no-tags) -p, –prune prune remote-tracking branches no longer on remote
–recurse-submodules[=<on-demand>]
control recursive fetching of submodules
–dry-run dry run
-k, –keep keep downloaded pack -u, –update-head-ok allow updating of HEAD ref
–progress force progress reporting –depth <depth> deepen history of shallow clone
–unshallow convert to a complete repository