git从入门到放弃
git基操
常用命令
git status # 查看状态
git add . # 添加
git commit -m "提交信息" # 提交
git log # git commit日志
git remote -v # 查看远程仓库地址
git push -u origin master # 本地仓库push到github上面
合并
git cherry-pick
- 挑选一个commit-id合并:
将另一分支的commit-id提交,合并到当前所在分支,在当前分支产生一个新的提交(commit-id、哈希值不同)。
git cherry-pick commit-id
- 挑选多个commit-id合并:
git cherry-pick commit-idA commit-idB
- 挑选连续的多个commit-id合并:
git cherry-pick commit-idA..commit-idB
该指令是将从commit-idA开始到commit-idB之间的所有commit-id提交记录都合并过来,需要注意的是,commit-idA必须比commit-idB提前提交,也就是说在被挑选的分支上,先有的commit-idA,然后才有的commit-idB。
小技巧Trick
如果不想使用原来的提交方案,希望合并提交。可以将原始git代码A复制一份为B,在A上使用git cherry-pick提取多个提交合并。再将主要修改部分,替换到B中。B再提交代码到远程。 =》 实现多提交合并
git rebase
git merge
快进式 VS 非快进式
快进式:简单将commit-id合并过来,不生成新commit-id。
git 合并某个提交commit到指定的分支上
Git 合并多次 commit
git加速
github国内镜像
-
备用
github加速:SwitchHosts
- 下载 SwitchHosts
- 添加规则,自动切换hosts
URL1: https://cdn.jsdelivr.net/gh/521xueweihan/GitHub520@main/hosts
URL2: https://raw.hellogithub.com/hosts
URL3: https://gitee.com/isevenluo/github-hosts/raw/master/hosts
github加速:FastGithub
git配置
下载
GIT官方网站下载:https://git-scm.com/downloads
用户信息配置
配置git全局用户信息(用户名、邮箱)。
git config --global user.name "rainbow-rain"
git config --global user.email "rainbow_lucky0106@163.com"
添加ssh key
使用git bash命令行生成公钥、私钥。
公钥填写到github上,私钥保存在本地。
ssh-keygen -t ed25519 -C "your_email@example.com"
推荐使用ed25519加密。RSA加密在新版本上可能无法使用。
GIT检查是否SSH通畅
ssh -T -v git@github.com
https://blog.csdn.net/hamupp/article/details/114581036
TortoiseGit
下载
下载:https://tortoisegit.org/download/
用户信息配置
添加ssh key
方案一:使用TortoiseGit自带PuTTYgen生成。(github新版本可能不支持RSA加密方式,导致github无法添加。)
方案二:使用git bash生成公钥、私钥后,再添加到TortoiseGit中。
可添加到tortoisegit的Pageant私钥管理工具中。
若无法识别,则在tortoisegit的PuTTYgen中加载,重新存储为ppk格式后,再添加到Pageant中。
TortoiseGit配置ssh key步骤
-
PuttyGen生成密钥、公钥并保存到C:\Users\用户名.ssh目录
-
GitLab中添加公钥
-
在TortoiseGit Pageant中添加私钥
[git]Window下git生成SSH Key和TortoiseGit添加putty秘钥免密配置
TortoiseGit工具疑难问题
重装问题解决
- 查看TortoiseGit Setting中的环境变量设置
- 在HKEY_CURRENT_USER -> Software -> TortoiseGit中ssh值更改为Tortoise真实路径
Problem:no supported authentication method available
鼠标右键 -> TortoiseGit -> Settings -> Network -> SSH Client 项
改为git中ssh.exe的路径
https://blog.csdn.net/freedomVenly/article/details/89285011
其它教程
GIT使用
初始化本地项目
- 新建文件夹
- 在git bash中执行
git init
git推送已有项目
github上创建Repository,获取仓库提交地址HTTPS / SSH。SSH方式需要配置公私钥。
.gitignore:排除文件
更多推荐
所有评论(0)