写在前面

github上想删除仓库中的某个文件或文件夹,亦或是重命名操作都很麻烦,这里提供一种vscode的解决方案。在vscode中克隆远程github仓库,然后对代码或文件进行编辑,最后提交即可,就和管理本地文件一样方便。

准备工作

  1. 下方地址下载安装git,已装请忽略
https://git-scm.com/downloads
  1. 打开命令行,输入下列代码并回车
git --version
  1. 正常显示版本号,则说明安装成功
C:\Users\ghgxj\Desktop>git --version
git version 2.27.0.windows.1

新建仓库

github上新建一个仓库,或者选择你之前已经建好的仓库,复制仓库地址,在vscode中会用到。

https://github.com/XavierJiezou/internet-speed-monitor

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_推送

克隆仓库

  1. 打开vscode,点击view-Command Palette…

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_vscode连接gitee远程仓库_02

  1. 在命令面板中输入git,点击Git: Clone

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_vscode连接gitee远程仓库_03

  1. 输入我们之前复制的仓库地址并回车

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_github_04

  1. 选择一个本地路径用于存放仓库

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_vscode连接gitee远程仓库_05

  1. 右下角显示正在将仓库下载到本地

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_vscode连接gitee远程仓库_06

  1. 下载完成后,点击Open

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_推送_07

提交修改

  1. 对文件进行编辑,以readme.md为例。修改之后,左边就会提示有几处进行了修改。我这里只修改了readme.md文件,所以角标显示的是1

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_vscode连接gitee远程仓库_08

  1. 点击对勾保存所有的修改

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_vscode连接gitee远程仓库_09

  1. 点击Yes

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_推送_10

  1. 输入描述信息,就是你到底修改了什么,如果没什么修改就输入空格,然后按回车(注意:如果什么都不输入,后面没法推送

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_github_11

  1. 点击Push推送更新。刷新一下网页,你就会发现内容已经更新了

vscode连接gitee远程仓库 vscode 提交代码到git远程仓库_github_12

温馨提示

浏览器中先把github登录上,因为中间过程会弹出github的网页授权验证。