Gitlab简单操作

1.创建自己的ssh

ssh-keygen -t rsa -C "dailinhui@pku.edu.cn"

2.生成的key在/home/yourusername/.ssh/id_rsa中,打开id_rsa.pub,里面就是自己的key
3.将key添加到自己Gitlab账号的配置中: 在User Settings->SSH Keys
4.在Github上建立自己的项目:
在这里插入图片描述
5. Git global setup:

git config --global user.name "Ixiaohuihuihui"
git config --global user.email "dailinhui@pku.edu.cn"

5.将自己的代码上传到gitlab上

git init Study1213
cd Study1213

可以将想上传的代码放在Study1213里面,例如data.py

git add data.py

提交代码到仓库

git commit -m "Study1213"

SSH的地址为:

git@gitlab.com:Ixiaohuihuihui/Study1213.git

在这里插入图片描述
链接到gitlab:

git remote add Study1213 git@gitlab.com:Ixiaohuihuihui/Study1213.git

push代码到服务器

git push -u Study1213 master

下次再上传代码,就只需要三步啦:
1.git add test.py
2. git commit -m "hello I am just test"
3. git push Study1213 master

出现的问题:

error: failed to push some refs to 'git@gitlab.com:hri_group_a/test1224.git'

在这里插入图片描述
因为原来我建项目的时候,有readme,但我本地没有readme,所以要先将远程服务器上面的文件拉下来。

branch 分支操作

分支操作包括:查看、新建、切换、删除
什么是分支?分支是为了将修改记录的整体流程分叉保存。分叉后的分支不受其他分支的影响,所以在同一个数据库里可以同时进行多个修改。
新建分支:

git branch test

切换当前所在分支:

git checkout test

在这里插入图片描述
准备在 test 分支中添加新的文件或修改,提交时用 git push Test1224 test 即可

git push Test1224 test

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值