Git常用操作
1.按照时间(正序)显示tag
git tag --sort=taggerdate
2.按照时间(倒序)显示tag
git tag --sort='-*authordate'
3.打标签
git tag -a v1.0 -m 'This is a v1.0 mistoneline'
4.补打标签
git tag -a v1.1 48d436de -m 'Add a tag that has forgot'
5.推送标签
git push v1.0
6.删除本地标签
git tag -d v1.1
7.删除远程标签
git push origin --delete tag v1.1
8.更新子模块
git submodule update --init --recursive (--remote pre_dl)
9.添加子模块
git submodule add -b master git@192.168.70.8:ChipSolution/ck810_sdk.git sdk
10.删除子模块
git rm --cached moduleA
rm -rf moduleA
rm .gitmodules
11.下载的时候顺带把子模块下载了
git clone --recurse-submodules git@192.168.70.8:sunchangji/ci_test.git
12.删除分支
git branch -d dev
13.删除远程分支
git push origin --delete dev
14.分支A_bracn和B_branch,只想将A_branch分支的某个文件f.txt合并到B_branch分支上。
git checkout A_branch
git checkout --patch B_branch f.txt
15.只是简单的将A_branch分支的文件f.txt copy到B_branch分支上
git checkout B_branch
cd path/to/f.txt
git checkout A_branch f.txt
16.提交信息msg
git log --pretty=format:"%an-%s" #效果:cuiweiwen-解决死循环的bug
17.左右2分支比对
git log --left-right dev...230M-JH_release >log
18.git revert commitid 反做某次提交(A B C 三次提交都merge了,现在不想要B的提交了,可以用revert)
19.git reset –hard commitid 回退到某次提交(A B C 三次提交,现在想回退到A,用reset)
20.存储凭证
git config --global credential.helper store
21.按日期获取修改记录
git log --since=”2019-11-10” --pretty=format:"%an~%s"
————————————————
%H: commit hash
%h: 缩短的commit hash
%T: tree hash
%t: 缩短的 tree hash
%P: parent hashes
%p: 缩短的 parent hashes
%an: 作者名字
%aN: mailmap的作者名字 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%ae: 作者邮箱
%aE: 作者邮箱 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%ad: 日期 (--date= 制定的格式)
%aD: 日期, RFC2822格式
%ar: 日期, 相对格式(1 day ago)
%at: 日期, UNIX timestamp
%ai: 日期, ISO 8601 格式
%cn: 提交者名字
%cN: 提交者名字 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%ce: 提交者 email
%cE: 提交者 email (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))
%cd: 提交日期 (--date= 制定的格式)
%cD: 提交日期, RFC2822格式
%cr: 提交日期, 相对格式(1 day ago)
%ct: 提交日期, UNIX timestamp
%ci: 提交日期, ISO 8601 格式
%d: ref名称
%e: encoding
%s: commit信息标题
%f: sanitized subject line, suitable for a filename
%b: commit信息内容
%N: commit notes
%gD: reflog selector, e.g., refs/stash@{1}
%gd: shortened reflog selector, e.g., stash@{1}
%gs: reflog subject
%Cred: 切换到红色
%Cgreen: 切换到绿色
%Cblue: 切换到蓝色
%Creset: 重设颜色
%C(...): 制定颜色, as described in color.branch.* config option
%m: left, right or boundary mark
%n: 换行
%%: a raw %
%x00: print a byte from a hex code
%w([[,[,]]]): switch line wrapping, like the -w option of git-shortlog(1)

浙公网安备 33010602011771号