命令行上传和更新本地项目到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
相关推荐
m0_694845578 小时前
tinylisp 是什么?超轻量 Lisp 解释器编译与运行教程
服务器·开发语言·云计算·github·lisp
June`8 小时前
muduo项目排查错误+测试
linux·c++·github·muduo网络库
weixin_66810 小时前
GitHub 2026年AI项目详细数据汇总表-AI分析-分享
人工智能·github
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2026-02-05)
ai·开源·大模型·github·ai教程
weixin_6681 天前
GitHub 2026年AI项目热度分析报告-AI分析-分享
人工智能·github
MicrosoftReactor1 天前
技术速递|GitHub Copilot CLI 斜杠命令速查表
github·copilot·cli
wu~9701 天前
GitHub永不遗忘,使用git push -f来覆盖的提交依旧保留
git·github
m0_694845571 天前
music-website 是什么?前后端分离音乐网站部署实战
linux·运维·服务器·云计算·github
独自破碎E1 天前
已经 Push 到远程的提交,如何修改 Commit 信息?
开发语言·github
jiang_changsheng1 天前
工作流agent汇总分析 2
java·人工智能·git·python·机器学习·github·语音识别