ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

从本地上传已有项目至github

2022-01-04 21:05:06  阅读:171  来源: 互联网

标签:git repository -- global github 本地 commit 上传


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

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

二,代码传至本地库: git 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项目下看到自己上传的代码。

标签:git,repository,--,global,github,本地,commit,上传
来源: https://blog.csdn.net/CharisJ/article/details/122302575

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有