github
玩转github
目录
[toc]
1、如何创建并维护好一个github上的开源项目?
0.💘 实战:如何创建一个属于自己的github仓库?-2022.4.14(亲测有效)
(1)注册github账号
来到GitHub官网:https:gitconfig--globaluser.email"2675263825@qq.com"
2️⃣ 生成ssh秘钥
然后生成密钥(公钥和私钥):
ssh-keygen-trsa-C"2675263825@qq.com"#备注:1.过程中按2次回车就好;2.也可以添加-b选项# ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
3️⃣ 复制ssh公钥到github
现在密钥已经生成,一般存放在(/c/Users/you/.ssh/id_rsa.pub.),我们运行下面的命令将密钥复制为粘贴板,等会儿会粘贴到github上去:
复制 id_rsa.pub 文件内容,登录 GitHub,点击用户头像→Settings→SSH and GPG keys,New SSH Key,输入复制的密钥信息,保存:
4️⃣ 验证:本地连接Github
右键单击鼠标,点击 Git Bash Here输入以下命令,如果如下图所示,出现你的用户名,那就成功了
$ssh-Tgit@github.com
(4)clone远程库到本地然后进行push/pull操作
🍀 测试过程:拉取一个自己github上刚创建好的仓库
hg@LAPTOP-G8TUFE0TMINGW64/d/IT/01IT/github_repo/06MyGitHub-OpenSourceProject$lshg@LAPTOP-G8TUFE0TMINGW64/d/IT/01IT/github_repo/06MyGitHub-OpenSourceProject$gitclonehttps:Cloninginto'Typora-TheKingOfCloudNotes'...remote:Enumeratingobjects:3,done.remote:Countingobjects:100%(3/3),done.remote:Compressingobjects:100%(2/2),done.remote:Total3(delta 0),reused 0 (delta0),pack-reused 0Unpackingobjects:100%(3/3),done.hg@LAPTOP-G8TUFE0TMINGW64/d/IT/01IT/github_repo/06MyGitHub-OpenSourceProject$lsTypora-TheKingOfCloudNotes/hg@LAPTOP-G8TUFE0TMINGW64/d/IT/01IT/github_repo/06MyGitHub-OpenSourceProject$cdTypora-TheKingOfCloudNotes/hg@LAPTOP-G8TUFE0TMINGW64/d/IT/01IT/github_repo/06MyGitHub-OpenSourceProject/Typora-TheKingOfCloudNotes(main)$lsREADME.mdhg@LAPTOP-G8TUFE0TMINGW64/d/IT/01IT/github_repo/06MyGitHub-OpenSourceProject/Typora-TheKingOfCloudNotes(main)$gs#个人第git status做了别名的OnbranchmainYourbranchisuptodatewith'origin/main'.#up to date最新的,最近的nothingtocommit,workingtreecleanhg@LAPTOP-G8TUFE0TMINGW64/d/IT/01IT/github_repo/06MyGitHub-OpenSourceProject/Typora-TheKingOfCloudNotes(main)
🍀 编辑好文件后,现在打算push仓库:
查看下当前环境:发现原来仓库的Readme.md文件被我删除了,但又新创建一个文件
$ls$gs
现在的目的就是如何把我当前新增的东西push到远程仓库呢?
我们再来看看当前的分支情况:
$gitbranch-av$gitk--all$gitlog--all--graph
现在有个问题,我该以什么分支名提交呢?,我们再来看看当前仓库信息
$cat.git/config
因为通过之前信息可以看到,我们仓库的主机别名叫做origin
,远程分支叫做main
,本地分支也是main
,因此后续在推送时该使用如下命令:
$gitpushoriginmain
🍀 再推送之前,我们先来把本次更新内容做一次commit:
$gitadd.$gitcommit-m"The first commit:Create file Readme-Typora-TheKingOfCloudNotes-2021.12.03.md"
🍀 开始推送:
淦,怎么还有验证呢。。。。。
报错了:。。。
按照楼上这位博主的方法修改下就好了,点个赞💖。
🍀 奇怪:又遇到问题了。。。
hg@LAPTOP-G8TUFE0TMINGW64/d/IT/01IT/github_repo/06MyGitHub-OpenSourceProject/Typora-TheKingOfCloudNotes(main)$gitpushoriginmainfatal:unabletoaccess'https:hg@LAPTOP-G8TUFE0TMINGW64/d/IT/01IT/github_repo/06MyGitHub-OpenSourceProject/Typora-TheKingOfCloudNotes(main)
解决办法:
配置后,终于提交成功了,666:
$gitconfig--globalhttp.sslVerifyfalse$gitpushoriginmain
完成。
出现这个问题最大可能是因为,我本地开了shadowflay
,需要专门配置下代理才可以,否则会一直卡主的,后面的那个(git pull/git push
一直卡主)问题现象也是一样的。
⚠️ o,shift,这个git pull,git push怎么这么慢呢,也连着vpn啊。。。。