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 仓库
相关推荐
极光技术熊14 小时前
Spring AI 从入门到精通:构建你的 AI 开发知识体系
后端·github
用户394839510755315 小时前
怎么让我的 Agent 真正"懂"我?——关于记忆、经验学习与预测的一些真实体验
github
远航_21 小时前
git submodule
前端·后端·github
fthux1 天前
如果你用 Mac,那你可能需要 Noti Shift
macos·开源·github
程序员天天困2 天前
Loop Engineering 实战:/goal 命令让 AI 自己写完整项目
github
徐小夕2 天前
我们开源了一款“框架无关”的思维导图编辑器,3分钟集成到任意系统
前端·javascript·github
小爷毛毛_卓寿杰2 天前
我把 397B 的「Agentic 大脑」塞进了 Xinference,一键部署 Nex-N2
人工智能·架构·github
小爷毛毛_卓寿杰2 天前
我把一个 3B 模型塞进了 Xinference,然后它干掉了 DeepSeek V3.2
人工智能·开源·github
凌奕2 天前
别用文档约束你的 Agent:聊聊 Agent 开发流程的思想
llm·github·agent
和你看星星2 天前
Git rerere:让重复冲突只解决一次
git