3

本地已有项目如何上传到github上

 2 years ago
source link: https://blog.p2hp.com/archives/8529
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

本地已有项目如何上传到github上 | Lenix Blog

大家好,我是小梅,公众号:「小梅的前端之路」 原创作者。

作为在前端领域不断探索的一员,在此记录开发中遇到的问题,如果你也遇到了相同的问题,希望本文对你有帮助。


一、github上新建一个仓库

具体步骤可以看网上的诸多教程

二、把本地项目初始化为一个git仓库

找到本地项目的根目录,依次执行

1、建立本地的git仓库

git init

2、将本地文件全部添加到本地的git仓库

git add .

此处如果报下面这个错误,则需要先执行:

git config --global core.autocrlf false

然后再执行git add .

  1. The file will have its original line endings in your working directory
  2. warning: LF will be replaced by CRLF in vite.config.js.
  3. The file will have its original line endings in your working directory

该报错的产生是因为换行符号转换的问题。git config --global core.autocrlf false命令就设置了默认不转换换行符

3、将刚刚添加的本地文件全部提交到本地git仓库

git commit -m "提交写的备注信息"

三、合并本地的git仓库和git上远程的仓库

1、将本地仓库与远程仓库关联起来

git remote add origin  [email protected]:Redxym/Vue3-Geek.git

3、拉取远程的代码

git pull origin master --allow-unrelated-histories

如果提示:说明远程没有文件需要拉取下来,直接进行步骤四提交本地文件到远程仓库即可

fatal: couldn't find remote ref master

如果提示,说明需要在github的设置中添加本级的SSH key,具体步骤参考网上的诸多教程

  1. [email protected]: Permission denied (publickey).
  2. fatal: Could not read from remote repository.

四、把本地仓库的代码提交到远程仓库

git push -u origin master

完结撒花。


❤️欢迎素质三连[点赞 + 收藏 + 评论]

我是小梅,有兴趣的话可以在微信搜一搜「小梅的前端之路」第一时间接收文章更新通知,一起沟通、学习成长呀。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK