从本地上传已有项目至github

一,初始化本地项目: git init

成功标志:Initialized empty Git repository in C:/你的本地项目路径/Project/.git/

二,代码传至本地库: git add .       (add与 .  中间有个空格)

成功标志:

warning: LF will be replaced by CRLF in .idea/inspectionProfiles/profiles_settings.xml.
The file will have its original line endings in your working directory 。。。。。。后面还有一大串

三,commit项目: git commit -m "test commit the project"

报如下提示:

Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

解决方案:按照提示输入自己的邮箱与用户名

git config --global user.email "你的邮箱"
 git config --global user.name "你的用户名"

继续执行:git commit -m "test commit the project" 成功

成功标志:

[master (root-commit) 7adea61] test commit the project
 1117 files changed, 204775 insertions(+)
 create mode 100644 .idea/.gitignore
。。。。。。等等

四,在github上新建Create a new repository

根据自己需求,选择public or private

最后点击Create repository绿色按钮,中间会有权限提示选择,由于我是private私有的,开了所有权限

五,github新建成功后,按照github提示页面代码如下执行git命令:

此句为github提示语句…or push an existing repository from the command line

git remote add origin https://github.com/你的项目名称.git
git branch -M main
git push -u origin main

在执行git push -u origin main 时报如下错:
fatal: helper error (-1): authentication prompt was canceled

因为我没有认证,用github登录名,密码认证不行,官网提示2021年8月13日后,必须要用a personal access token 详细的personal access token创建点击Creating a personal access token - GitHub Docs

六,再次执行git push -u origin main ,会弹出一个小框,把 personal token输入到小框即可。

至此从本地上传已有项目至github已完成,可在自己的github项目下看到自己上传的代码。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值