type
status
date
slug
summary
tags
category
icon
学习进度
在VSCode上自己写的代码如何上传到 🐱GitHub 🤔
👇可以按照以下步骤操作:
1️⃣首先,在 GitHub 上创建一个账号并登录。(需要VPN)
2️⃣登录成功后,在页面右上角找到 “+” 符号,然后点击选择 “New repository” 创建一个新的仓库。
![notion image](https://prod-files-secure.s3.us-west-2.amazonaws.com/3de6d188-8727-46da-9e23-6bba02fc680b/9a7e91f6-6538-401b-a2b5-f48efd4ba1de/Untitled.png)
3️⃣给你的新仓库起个名字并添加描述,选择公共或私有仓库,然后点击 “Create repository”。
![notion image](https://prod-files-secure.s3.us-west-2.amazonaws.com/3de6d188-8727-46da-9e23-6bba02fc680b/538bd3aa-9c14-46b7-b1a4-b3d4d52afb11/Untitled.png)
![notion image](https://prod-files-secure.s3.us-west-2.amazonaws.com/3de6d188-8727-46da-9e23-6bba02fc680b/514bdfe0-e2d2-4229-b3a1-9a91f539e0d0/Untitled.png)
4️⃣在本地计算机上,将要上传的代码一起存储在一个文件夹中。
![notion image](https://prod-files-secure.s3.us-west-2.amazonaws.com/3de6d188-8727-46da-9e23-6bba02fc680b/2cf1d3f8-b9c9-4616-84db-a3f489dad76d/Untitled.png)
5️⃣(提前下载安装Git并配置好环境变量)用 Git 进行初始化。在终端窗口中,进入项目文件夹并输入以下命令:
git init 👈
将代码添加到 Git 中:
git add . 👈
确认代码是否成功添加到 Git 中:
git status 👈
提交代码更改:
git commit -m "自定义提交注释" 👈
6️⃣关联远程仓库:
git remote add origin http://github.com/xxxxx/xxxxx.git 👇
![notion image](https://prod-files-secure.s3.us-west-2.amazonaws.com/3de6d188-8727-46da-9e23-6bba02fc680b/32cf6c49-36f8-4e30-a405-9c4a08c1c4ef/Untitled.png)
😊点开刚才在GitHub创建好的仓库,按步骤拷贝这个地址到终端关联远程仓库用。
提醒:留意一下,第一个“xxxxx” 和 第二个“xxxxx” 是不是你刚才创建的仓库的用户名和仓库名称即可。
7️⃣将代码推送到 GitHub 上的远程仓库:
git push -u origin master 👈
这时去刷新 GitHub 仓库页面,上传的代码就会在上面显示出来啦。🎉🎉🎉
8️⃣最后就是GitHub默认把main作为主分支,我们需手动将默认main修改为master。
![notion image](https://prod-files-secure.s3.us-west-2.amazonaws.com/3de6d188-8727-46da-9e23-6bba02fc680b/a9786916-c27f-45bb-aec4-bd18c0f22bf9/Untitled.png)
第一步 👇
![notion image](https://prod-files-secure.s3.us-west-2.amazonaws.com/3de6d188-8727-46da-9e23-6bba02fc680b/2aadc739-76f5-4923-b5e5-2224f587543e/Untitled.png)
第二步👇
![notion image](https://prod-files-secure.s3.us-west-2.amazonaws.com/3de6d188-8727-46da-9e23-6bba02fc680b/cc27004c-491b-4229-971c-545600ced143/Untitled.png)
🤪这样就成功的把我们本地的代码上到GitHub了,后期如需更改代码直接在终端操作Git就可以更新到GitHub啦。 💯💯💯
- 作者:heliang
- 链接:https://heliang.fun/article/GitHub%20uploading
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。