本篇用于记录将本地工程代码上传到远程的分支上同时记录一些常用的指令
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 //查看所有分支