vscode中使用git、githup的基操

一、git提交

配置账户密码

查看用户信息

bash 复制代码
git config --global user.name # 查看用户名 
git config --global user.email # 查看邮箱

账户配置

bash 复制代码
# 设置全局用户名和邮箱
git config --global user.name "你的用户名"
git config --global user.email "你的邮箱" 
# 查看所有 Git 配置 
git config --list

提交

基操

添加和提交

bash 复制代码
git add .
git commit -m "这里是提交注释"

git log 查看历史提交

二、公共云服务仓库

网络问题参考:
GitHub push失败-Failed to connect to github.com port 443: Timed out_github推送不上去 faid to connect-CSDN博客

提交至githup

bash 复制代码
git init
git add 文件名
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/WYend/Myblog.git
git push -u origin main
  1. git branch -M main
    • branch:操作分支的命令
    • -M:强制重命名分支
    • main:将当前分支重命名为 main(现在主流的默认分支名,替代了传统的 master)
    • 作用:规范分支名称,与远程仓库主流命名保持一致
  2. git remote add origin https://github.com/WYend/Myblog.git
    • remote add:添加远程仓库地址
    • origin:给远程仓库起的别名(通常默认用 origin)
    • 后面的 URL 是 GitHub 上创建的仓库地址
    • 作用:建立本地仓库与远程 GitHub 仓库的关联
  3. git push -u origin main
    • push:将本地仓库的提交推送到远程仓库
    • -u:设置上游关联(后续可以直接用 git push 而不用指定远程和分支)
    • origin:指定推送到哪个远程仓库(前面设置的别名)
    • main:指定推送本地的 main 分支到远程的 main 分支
    • 作用:将本地的第一次提交上传到 GitHub 仓库
相关推荐
苏子寒1 小时前
Nano-VLLM全代码解析笔记(10)-GemmaRMSNorm和MRoPE
笔记·机器学习·ai·nlp·vllm
峰向AI12 小时前
316k+ Star 史上第二热门项目,没有一行代码
github
dong_junshuai12 小时前
每天一个开源项目#86 ECC:245K星的 Agent 工程操作层
开源·github·agent
阿里云大数据AI技术12 小时前
Agentic Search 2.0:从单轮对话迈向企业级 AI 搜索自动驾驶Agent
人工智能·elasticsearch·agent
Natural13 小时前
混合检索 + RRF + Rerank 实战评测:三条路线在 47 个真实问题上的取舍
github
Elasticsearch15 小时前
你的 AI agent 需要一个不在场证明:Elastic 中 Agent Builder 的可观测性和审计追踪
elasticsearch
一点一木15 小时前
憋了7周没动静,OpenClaw 2.0带着16000个PR杀回来了
人工智能·github
Elasticsearch18 小时前
仪表板活动日志:了解哪些 Kibana 仪表板会被使用
elasticsearch
一点一木19 小时前
🚀 2026 年 8 月 GitHub 十大热门项目排行榜 🔥
人工智能·github
工藤孤独20 小时前
Git Worktree 从零到多智能体实战
git