Skip to content

常用命令

创建新分支(清除all commit)

https://git-scm.com/docs/git-checkout

git checkout --orphan <new-branch>

git 修改branch名字

git branch -m <new name>

or

git branch -m <oldname> <newname>

git 挑选commit

如:在 branch dev 下,合并 prod 的commit

git cherry-pick commit1 commit2

# commits one by one
# git cherry-pick commit1 commit2 commit3 commit4 commit5
# example:
git cherry-pick 1e038f10 2f028f10 34138b11
# commits by range
# git cherry-pick A^..B
# example:
git cherry-pick 6653c90^..481981f

输出commit

tac 行反转,ORS 间隔

git log -10 --pretty="%h" | tac | awk "{print}" ORS=' '

打包

git archive --format=zip --output mpy.zip master