惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客 on 老刘博客

博客托管平台换成edgeone pages 博客评论换回Giscus 把GotoSocial嵌入到Hugo 给Hugo PaperMod主题添加一个漂亮又简洁的友情链接页面 重新启航 Hello World Hugo-papermod主题的优化记录 朋友们,博客改名加换域名了! 重新弄了下博客环境 博客改名字了
如何使用git并把代码提交到GitHub
老刘 · 2023-11-15 · via 博客 on 老刘博客

这篇文章纯粹给初学者看的,大佬请无视。使用Hugo之后,为了方便推送方便,一般要用到git这个软件。今天就来谈谈git具体的用法。

git的用法

设置用户名

因为git可以用来团队协助方面,设置用户名的目的是为了让别人知道,你是谁,这个程序的bug是谁提交的😰。

1
2
git config --global user.name "xxxx"
git config --global user.email "xxxx@qq.com"

设置本地仓库

选择你项目的文件夹,在里面打开终端,运行如下命令:

在每次修改完程序后,运行如下命令提交:

1
2
git add .
git commit -m "简短的说明,本次提交了什么"

设置远程仓库

很多时候我们还要把代码提交到GitHub上去,当然你也可以创建自己的远程git服务器,这里不涉及。

首先,用ssh生成公钥

1
ssh-keygen -t rsa -C "****@qq.com"

一般会在~/.ssh/这个文件夹里,生成两个文件,打开后缀为pub的那个文件。

1
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCh9zv7aD0IQAen8wC5slQPlE9H2Jjh6Z8v7YShZGXaFxq2Hd/e5v0KTLDHuL0DSItsbQGVMiLuJhPE3f1ypxAruj14Frak4+U5WZhV6xTSeQVwIWd8QyMBaYNjv7s49nb+tz9NAYrzu8ZNT8+2s1vUXCI5K6vPNMTax0KrAjmqOZ0sbcSzmz57LVpJqadc9Svuh84X65LH2XuzfNudzmrMIK3uu5GoFosqY4Y+tu3ssvmeUKWfFRM14Gab0I6funZZh5EdRv2/ltkEdzIRl01FQTAyo5rnzaY4jPhCR5ANd1smzo+h4KvqIK3uux96Hs= ****@qq.com

然后把copy这个文件的内容,打开GitHub网站,登录自己的账户,在设置里找到ssh那个选项,提交进去可以了。

连接远程代码仓库提交代码

1
git remote add origin git@github.com:GitHub用户名/我的项目.git 

然后,提交代码到自己的项目里:

1
git push -u origin main

以后的提交可以不用-u这个参数了。

把远程仓库的代码下载到本地

远程Pull的时候出现错误

这是我的另一个项目在pull的时候催化下的错误。在从远程pull的时候出现了,error: Your local changes to the following files would be overwritten by merge:这个错误提示,提示的是数据库文件,是因为因为网站访问的原因,导致本地数据库和远程的数据库文件不一致。其实后期是不会用到这个数据库文件的。因此,丢弃本地的修改