git常用技巧1:将本地项目或代码提交到GitLab的远程分支上与合并到master

本篇用于记录将本地工程代码上传到远程的分支上同时记录一些常用的指令

1.提交至远程分支:

第一步:将对应项目拉取到本地:即git clone+项目地址,比如

git clone https://github.com/LZY_Develop/ORB_SLAM2.git(gitlab服务器上类似形式)

可能会遇到的问题:
case1:

The authenticity of host '11.1.201.204 (11.1.201.204)' can't be established.
ECDSA key fingerprint is SHA256:Y/ESAjMogngV3IGxqCQ5XBPp7cBxRuT8vKtjomi7XlM.
Are you sure you want to continue connecting (yes/no)? 
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决方法:

ssh -o StrictHostKeyChecking=no 11.1.201.204 

输入相应的密码即可。
case2:

Warning: Permanently added the RSA host key for IP address '13.229.188.59' to the list of known hosts.
sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决方法:

eval "$(ssh-agent -s)"
ssh-add

然后切到当前的路径下。即

cd ORB_SLAM2

第二步:切换到分支,比如在将要提交的项目里面有我的一个分支叫liuziyang,如果没有就创建分支

git branch liuziyang

切换到该分支下

git checkout liuziyang

第三步:复制代码,即将要提交的代码复制到ORB_SLAM2目录下。即我有一个localization文件夹要提交到远程分支,复制它到ORB_SLAM2目录下。依次执行:

git add .     (注意:add与句号间有空格,否则会报错)
git commit -m "change log" 
git push origin **liuziyang**

2.合并分支到主干master上:

1.切换到主干

git checkout master

2.合并分支

git merge 分支名

3.添加文件

git  add .

4.合并与提交

git commit -m "change log"
git push origin master

常用指令:

git checkout  分支名		//切换分支
git checkout -b 分支名		//新建分支
git branch -a //查看所有分支
  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值