git入门 代码推送与拉取
本文最后更新于70 天前,其中的信息可能已经过时,如有错误请发送邮件到aptim@aptim.top

wordpress个人博客通过git实现个人电脑(win11 PC)与服务器(ubuntu)之间的代码推送与拉取。

github配置

1、首先需要在GitHub上将linux服务器与个人PC的SSH公钥添加到github上面,具体操作步骤如下。 登录github,点击右上角头像,Settings-SSH and GPG keys-New SSH key,将Authentication keys添加到这里即可

Pasted image 20250901160113
2、新增一个新的repository存储仓,具体位置在github页面右上角的“+”按钮,随后命名。
Pasted image 20250901160529

linux配置

1、Server端配置,指定需要同步的目录或文件,本文将wordpress的根目录为例

# 1. 安装 Git
sudo apt update && sudo apt install git -y

# 2. 添加远程仓库地址
# serverIP:服务器地址
# userName:用户名称
# repositoryName.git:仓库名称
# my-project.git:
git remote add origin git@[serverIP]:[userName]/[repositoryName.git]

# 3. 验证
# 成功结果
# Hi xxxxx! You've successfully authenticated, but GitHub does not provide shell access.
ssh -T git@github.com

2、Server推送代码到github仓

# 1、添加文件到暂存区
# git add . 表示所有文件
git add xxx

# 2、提交文件并添加提交信息
git commit -m “提交信息”

# 3、推送到代码仓库
git push

pc配置

pc拉取github仓的代码

# 1、克隆代码
git clone git@[serverIP]:[userName]/[repositoryName.git]

# 2、拉取最新代码
git pull
加油୧(๑•̀⌄•́๑)૭
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇