在gitlab上新建一个project后,有如下教程提示:
1、Git global setup (初始设置,设置登录名和密码)
git config --global user.name "***"
git config --global user.email "***@stu.ouc.edu.cn"
2、Create a new repository(打开本地终端,下载并建立git链接)
git clone https://gitlab.com/DJofOUC/temp.git
cd temp
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
3、Push an existing folder(上传一个已有的项目文件至gitlab)
cd existing_folder
git init
git remote add origin https://gitlab.com/DJofOUC/temp.git
git add .
git commit -m "Initial commit"
git push -u origin master
4、Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/DJofOUC/temp.git
git push -u origin --all
git push -u origin --tags
常见问题(长期更新。。。)
1、从本地更新至仓库
git add temp_file
git commit -m "添加文件"
git push origin master
2、命令回退
git reset --hard HEAD~1
3、查看日志
git log
4、查看状态
git status
5、merge冲突
基本上只要先git pull,然后手动修改冲突,再git push即可
6、git clone 报错:error: The requested URL returned error: 401 Unauthorized while accessing http://*****
(亲测有效)
解决方法一:指定用户
git clone https://github.com/org/project.git
换成
git clone https://username@github.com/org/project.git
或者
git clone https://username:password@github.com/org/project.git
在push或者pull出出现的话,则需要更改远程地址
git remote set-url origin https://username@github.com/org/project.git
参考链接:
(1)git使用教程:
https://blog.csdn.net/YJG7D314/article/details/104551896
https://mp.weixin.qq.com/s/V9Nol6BFiT2dv9n3irI7bg