命令行上传和更新本地项目到github的步骤

一、上传项目

0)如果项目本身有git残留,需要先移除旧的origin:

bash 复制代码
git remote remove origin

1)首次上传:

bash 复制代码
git remote add origin https://github.com/用户名/项目名称

2)然后推送:

bash 复制代码
git push -u origin main

二、更新项目

1)添加新增文件到git,以下代码是添加根目录的所有文件,注意 "." 前面要有空格:

bash 复制代码
git add .

2)添加说明注释(可选):

bash 复制代码
git commit -m "写一段对新增文件的说明注释"

3)推送到github(操作同上):

bash 复制代码
git remote add origin https://github.com/用户名/项目名称
git push -u origin main
相关推荐
数据大魔方1 天前
【期货量化实战】跨期套利策略:价差交易完整指南(TqSdk源码详解)
数据库·python·算法·github·程序员创富
数据大魔方1 天前
【期货量化实战】螺纹钢量化交易指南:品种特性与策略实战(TqSdk完整方案)
python·算法·github·程序员创富·期货程序化·期货量化·交易策略实战
Cx330❀1 天前
Git 多人协作全攻略:从入门到高效协同
大数据·elasticsearch·搜索引擎·gitee·github·全文检索·gitcode
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2026-1-9)
开源·大模型·llm·github·ai教程
lpfasd1231 天前
系统、详细地介绍 GitHub 官方 API 的能力边界
github
KevinShi_BJ1 天前
Github Copilot 实践
github·copilot
秋雨雁南飞1 天前
图床软件 PicGo + Github
github·picgo·图床
moment&forever1 天前
GitHub 托管 API 地址配置文件:实现零成本云配置托管
github
小龙2 天前
【Git 报错解决】本地无有效提交无法推送(`src refspec main does not match any`)
git·github·报错
行百里er2 天前
一个还没写代码的开源项目,我先来“画个饼”:Spring Insight
后端·开源·github