Github新建仓库并添加本地代码或文件

Posted by Nefelibata on Wed 2024-04-24 | | about 1 mins
Last Modified on Thu 2024-05-23

1 在cmd创建新仓库

1.1 在github页面上新建仓库

1.2 在本地新建仓库

首先,创建.gitignore文件,将不需要上传的文件和文件夹写进去,例如:

1node_modules
2.DS_Store
3dist
4dist-ssr
5coverage
6*.local
7
8/cypress/videos/
9/cypress/screenshots/

接着,执行以下命令

1echo "# vue3_test" >> README.md
2git init		# 初始化
3git add .		# 添加本地所有文件
4git commit -m "first commit"		# 初始化
5git branch -M main		# 初始化
6git remote add origin https://github.com/HuuuuuuO/vue3_test.git		# 初始化
7git push -u origin main		# 初始化

2 从cmd推送一个已经存在的仓库

1git remote add origin https://github.com/HuuuuuuO/vue3_test.git
2git branch -M main
3git push -u origin main