git 点滴

把本地创建好的分支,强行推送到远程库创建
git push -u origin <branch>
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


正确的流程:
按照常规修改代码, commit 代码,然后 git tag -a v2.0.8 -m “…”, 然后 git describe 验证查看, git push origin tag v2.0.8 ,去另外的 git 客户端 git pull 就可以看到新的标签下载, 用 git describe 验证当前 commit 是否是正确的 v2.0.8 标签

作者: 甬洁网络

--移动互联网&物联网技术提供商