Git配置,用vscode编写代码并提交进github

Git工作大致原理

1_add
2_commit
3_push
pull
workspace
文件
Repository
Remote

电脑配置Git步骤—github仓库

clone远程仓库+配置

  • 打开github(或新建)一个仓库,记下仓库地址;
  • 配置用户名和邮箱(github注册邮箱):
    打开下载好的 git bash,输入:
    (ps:复制粘贴会失灵+空格不可少+两个“-”之间没有空格)
  1. git config - -global user.name '你的用户名
  2. git config - -global user.email '你的email
  3. git clone '你的仓库地址
    全程英文输入
    不显示出错再输入下一步
  • 这时桌面会出现一个和仓库同名的文件夹;

下面是本地编辑并提交到github的一般步骤(不用VScode的情况下)

add

  • 在文件夹里新建一个文件
    这里我用 a.html 为例;
  • git bash 输入:
    1. cd 你的文件夹名字
    1. git add a.html

commit

  • git bash 输入:
    git commit -m 'a.html’

push

  • git bash 输入:
    git push
    等待一会儿
    第一次会跳出登录界面,需要登录github;
    登录之后就提交完成,登录github的仓库会发现文件出现;

pull和checkout

pull

  • git bash 输入:
    git pull
    从github仓库下载最新项目

checkout

  • git bash 输入:
    git checkout
    找回原先的项目

VS Code 编写代码如何提交到github仓库

下载Git插件:GitLens — Git supercharged

  • 打开项目文件夹——编辑文件并保存
  • 打开左端的 源代码管理器 ,查看更改的文件
  • 按“+”号 暂存更改
  • 按“√” 提交——输入提交信息——enter键
  • 按"√"后面的"···" ——推送
  • 完成

猜你喜欢

转载自blog.csdn.net/qq_46590483/article/details/107127327