1、克隆Gitlab仓库:
git clone http://192.168.248.131:30080/root/test.git
2、克隆GitHub仓库:
git clone https://github.com/huanzi-qch/springBoot.git
3、将GitHub仓库中的代码移动带Gitlab仓库:
1、GitHub仓库名为 springBoot
2、Gitlab仓库名为 test
3、进入springBoot仓库,将自己所需要的代码移动到test仓库:
1、进入springBoot仓库:
cd springBoot
ls
2、移动代码到test目录:
mv ./springboot-cache /root/test/
cd /root/tesst
ls
4、进入test目录,将代码提交到gitlab远程仓库:
1、进入test目录:
cd /root/test
2、查看原曾仓库信息:
git remove -v
3、查看要提交代码的远程分支:
git branch -a
4、切换到要上传代码的分支:
git checkout 选择分支
5、提交当前代码到暂存区:
git add .
6、将保存到暂存区的代码永久保存到git仓库:
git commit -m "提交代码"
7、将本地main分支上的提交,推送到名为origin的远程仓库中:
git push origin main
输入gitlab仓库的用户名和密码
8、web端登录Gitlab,查看代码是否提交到相应仓库
5、Git常用代码:
1、查看git文件中载入的远程信息:
git remove -v
2、给代码仓库替换 新代码仓库地址:
git remove set-url origin 新代码仓库地址
git remove set-url origin https://github.com/huanzi-qch/springBoot.git
3、查看新仓库地址是否替换成功:
git remove -v
4、查看自己所在的分支:
git branch -a
5、更新本地Git仓库中的远程跟踪分支,清理已经被删除的远程分支:
git remote update origin --prune # 更新本地git仓库中的远程跟踪分支 git remote update origin ,清理已经被删除的远程分支 --prune
6、切换分支:
git checkout 你的分支
git checkout main
git checkout master
7、提交当前代码到缓存区:
git add .
8、将缓存区的代码永久记录到git仓库:
git commit -m "写你这次干的事儿"
9、将本地main分支上的提交推送带Gitlab远程仓库中:
git push origin main
输入gitlab仓库的用户名、密码
10、修改本地分支名称;
1、将本地master分支的名修改为main分支名:
git branch -m master main
11、拉取main分支代码:
git pull origin main