步骤
1.创建仓库

2.记下仓库的url

3.在本地初始化仓库
路径要在项目下
cd /path/to/your/vue-project
git init

4.创建touch .gitignore文件
在项目根目录下创建 .gitignore 文件,用于指定 Git 忽略哪些文件或文件夹

5.添加和提交项目文件
将文件提交到版本控制中
git add .
git commit -m "Initial commit"
6.添加远程仓库并推送代码
将远程仓库添加到本地 Git 仓库,并推送代码到 GitHub。
git remote add origin https://github.com/5z3c/test3.git
git push -u origin master
可能的问题
1.Git 无法识别你当前的身份信息(用户名和邮箱)的问题。Git 需要这些信息来记录谁提交了代码
git config --global user.name "你的用户名"
git config --global user.email "你的邮箱"
2.fatal: remote origin already exists.
原因:你已经将一个远程仓库添加并命名为origin了,而现在你在尝试将另一个远程仓库添加并命名为origin
解决:
方法1.使用set-url修改origin仓库的url
git remote set-url origin [email protected]:your_username/your_repository.git
方法2.先将已经添加过的,命名为origin的远程仓库给删了,然后重新添加
git remote rm origin
git remote add origin [email protected]:your_username/your_repository.git
方法3:既然你已经将origin指向了某个远程仓库,那现在你换个名字指向另一个远程仓库就可以了
git remote add origin2 [email protected]:your_username/your_repository.git
如果这样,那么push时就要
git push origin2 master