单主机上,多个Git用户,同时提交下载代码的配置

==========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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值