Git使用技巧
修改commmit信息
git shortlog --format='%H|%cn|%at|%s'
git filter-branch -f --env-filter '
CORRECT_NAME="xx"
CORRECT_EMAIL="xx@xx.com"
CORRECT_DATE="@1585578820 +0800"
if [ "$GIT_COMMITTER_DATE" = "@1594294083 +0800" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
export GIT_COMMITTER_DATE="$CORRECT_DATE"
fi
' --tag-name-filter cat -- --branches --tags
git push --force --tags origin 'refs/heads/*'
撤销工作区的文件修改
git checkout .
# 或者指定单个文件
git checkout -- xxx.xxx
GPG认证
git diff相关
# 工作区和暂存区的差别
git diff
# 暂存区和版本库的差别(常用)
git diff --cached
# 查看工作区和版本库的差别
git diff HEAD
git rebase 实践
- 确保master分支未被其他人改动
- feature分支先rebase到master上
- master分支继续进行rebase,squash提交
git rebase分支合并2
将master分支超前的改动合并到dev分支上git rebase master dev