==========0. 公私钥准备==========
[root@host-10-57-72-19 ~]# chmod 600 /root/.ssh/sun_id_rsa.pub
[root@host-10-57-72-19 ~]# chmod 600 /root/.ssh/sun_id_rsa
==========1. 全局GIT配置=======
[root@host-10-57-72-19 ~]# cat ~/.gitconfig
[url "ssh://sunshine@gerrit.xxx.com"]
pushInsteadOf = ssh://sunshine@gerritro.xxx.com
==========2. 本地GIT配置==========
[root@host-10-57-72-19 ~ /home/sunjun/RepositoryForGit/VNFP]# cat .git/config
[remote "origin"]
url = ssh://sunshine@sunyang:29418/vCube/VNFP //url = ssh://sunshine@gerritro.xxx.com:29418/vCube/VNFP
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
name = 孙阳 // git config --local user.name "孙阳"
email = sun.yang@163.com // git config --local user.email "sun.yang@163.com"
==========3. 全局SSH配置==========
[root@host-10-57-72-19 ~]# cat /root/.ssh/config
#服务器别名,clone代码时有用
Host sunyang
#服务器地址
HostName gerrit.xxx.com
#用户名
User 孙阳
#密钥
IdentityFile ~/.ssh/sun_id_rsa
========== 附录 A. 常用配置 ==========
1.全局参数:
$ git config --global user.name "sunjd" # 设置用户
$ git config --global user.email "sunjd@sibet.ac.cn" # 设置邮箱
$ git config –global core.quotepath false #支持中文
# 设置镜像(更新:不用设置)
//$ git config --global url."ssh://12340456@gerrit".pushInsteadOf ssh://12340456@gerritro
//$ git config --global http.proxy "localhost:1080"
# 查看配置
$ git config --global --list //全局配置
$ git config --local --list //本项目局部配置
2. 克隆库中源代码
$ git clone http://ip:8000/gitlab-instance-f256eb7f/eecl-ecl.git
cd eecl-ecl
3. 添加新变化或文件
$ git add . //git add ./xxx.c
4. 解释本次变化
$ git commit -m "修改文件:xxx.cd" //git commit --amend 本次提交修补
5.提交变化到origin远端库main分支
$ git push origin HEAD:main
下面的命令不建议经常使用。
$ git reset --hard origin/main
$ git pull
git 下载子模块命令
方法一:git clone --recursive
git config --global http.sslVerify false
git clone --recursive https://github.com/embedded-software-laboratory/embeddedRTPS-Linux.git
git clone https://github.com/PX4/PX4-Autopilot.git --recursive
git submodule update --init --recursive
方法二:git submodule update --init
git config --global http.sslVerify false
git clone https://github.com/embedded-software-laboratory/embeddedRTPS-Linux.git
cd embeddedRTPS-Linux
git submodule update --init --recursive
mkdir build
cd build
cmake ..
make -j4