git命令行推送新项目至github
1、idea创建一个maven项目
2、github上创建同名仓库
3、在本地项目下开启git bash 命令
依次输入如下命令
git remote add origin https://github.com/账号名/项目名.git
git add .
git commit -m "init project"
git push -u origin master
当输入命令"git remote add origin https://github.com/账号名/项目名.git"
出现报错为"remote origin already exists."
时,做如下处理:
// 删除关联的origin的远程库
git remote rm origin
// 再输入命令
git remote add origin https://github.com/账号名/项目名.git
4、输入github账号和密码
当输入密码报错为remote: Support for password authentication was removed on August 13, 2021.
时,做如下处理:
- 在github中生成token。Settings –> Deverloper settings –> Personal access tokens –> Generate new token
- 复制生成的token,粘贴至输入密码的位置,然后可以在github上查看是否push成功了