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

推荐订阅源

Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
The Register - Security
The Register - Security
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
P
Proofpoint News Feed
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
The Last Watchdog
The Last Watchdog
F
Fortinet All Blogs
S
Schneier on Security
Help Net Security
Help Net Security
Security Archives - TechRepublic
Security Archives - TechRepublic
C
Check Point Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
I
InfoQ
T
The Blog of Author Tim Ferriss
Cisco Talos Blog
Cisco Talos Blog
Stack Overflow Blog
Stack Overflow Blog
T
Troy Hunt's Blog
人人都是产品经理
人人都是产品经理
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cyber Attacks, Cyber Crime and Cyber Security
雷峰网
雷峰网
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
Forbes - Security
Forbes - Security
Vercel News
Vercel News
S
Security Affairs
美团技术团队
P
Privacy & Cybersecurity Law Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Spread Privacy
Spread Privacy
Attack and Defense Labs
Attack and Defense Labs
IT之家
IT之家
U
Unit 42
Recorded Future
Recorded Future
W
WeLiveSecurity
PCI Perspectives
PCI Perspectives
P
Palo Alto Networks Blog
H
Hacker News: Front Page
S
Security @ Cisco Blogs
博客园 - 【当耐特】

齐物论 on 老刘博客

暂无文章

如何使用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:这个错误提示,提示的是数据库文件,是因为因为网站访问的原因,导致本地数据库和远程的数据库文件不一致。其实后期是不会用到这个数据库文件的。因此,丢弃本地的修改