Git学习笔记

1.不再允许SHA-1

1.1 问题描述

>> ERROR: You're using an RSA key with SHA-1, which is no longer allowed. Please use a newer client or a different key type.

1.2 解决办法

  • (1) 生成新版ssh-key
>> ssh-keygen -t ecdsa -b 521 -C "email"
  • (2) 打印生成的ssh-key
>> cat ~/.ssh/id_rsa.pub
  • (3) 将生成ssh-key添加到git上即可

1.3 参考资料

  • [1] https://blog.csdn.net/Mr_kanger/article/details/123741702

2.配置git的用户名和邮箱

2.1 配置git的用户名

>> git config --global user.name "用户名"

2.2 配置git的邮箱

>> git config --global user.email "用户邮箱"

3.删除远程不存在的git分支

>> git remote prune origin

4.查看当前git存在的分支

>> git branch -a

5.切换git的分支

>> git checkout [分支名]

6.删除git分支

6.1 删除本地分支

>> git branch -D [分支名]
>> git branch -delete [分支名]

前一个是强制删除

6.2 删除远程分支

>> git push origin --delete [分支名]

7.拉去git远程代码

>> git pull

8.推送代码到git远程

>> git push

9.设置git远程仓库地址

>> git remote set-url origin [git地址]

10.拉去远程git项目及子模块

>> git clone --recursive [git地址]

11.无痕回撤掉git记录

>> git reset --hard HEAD~[N条记录]
>> git push -f origin

12.批量修改git记录

#!/bin/sh

>> git filter-branch --env-filter '

OLD_EMAIL="原邮箱地址"
CORRECT_NAME="新用户名"
CORRECT_EMAIL="新邮箱地址"

if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
>> git push origin --force --all
>> git update-ref -d refs/original/refs/heads/master

参考资料

(1) [Github实战]批量修改git commit记录中的用户名和邮箱

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值