GitLab相关

配置:只对本台电脑生效。在Linux上的ssh-key对Linux的指定机器生效,在Windows机器add的对Windows机器生效,各配各的。

下面是在ubuntu上配置的:

1.账户配置

git config --global user.name "xxx"

git config --global use.email tang@xxx.com

root@ubuntu:/home/xxx/trunk/vod# git config --list
user.email=xxx.tang@xxx.com
user.name=git@bjgitlab.xxx.com
core.excludesfile=~/.gitignogtire
use.email=git@bjgitlab.xxx.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://bjgitlab.xxx.com/golang/vodserver.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

2. 生成ssh-key:

root@ubuntu:/home/xxx/trunk/vod# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
86:e9:13:1e:e8:ce:54:95:ed:0b:a4:69:41:c7:85:d7 root@ubuntu
The key's randomart image is:
+--[ RSA 2048]----+
| ...o.. |
| . .oo. E |
| . +.. |
| . O . |
| . X S . |
| . = + . . |
| o + . |
| + . |
| o |
+-----------------+

root@ubuntu:/home/xxx/trunk/vod# cat /root/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA65SSWjmvShnLpXCeRawpR7FjkXLSWYZP6cT/GZ+oCDbMPy/j
BoF+r42RhULbmgOqW/gZY。。。。。。
-----END RSA PRIVATE KEY-----
root@ubuntu:/home/xxx/trunk/vod# cat /root/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDrlJJaOa9KGculcJ5FrClHsWORctJZhk/pxP8Zn6gINsw/L+MGgX6vjZGF。。。。。。

3. 添加ssh-key

复制 /root/.ssh/id_rsa.pub 的内容到 https://bjgitlab.xxx.com/-/profile/keys 中

关键一步:需要把 ssh-keygen 生成的key复制到页面上

4. 代码操作

4.1 克隆代码

git clone git@bjgitlab.xxx.com:golang/vodserver.git


root@ubuntu:/home/xxx/trunk/vod# ll
total 12
drwxrwxr-x 3 xxxx xxx 4096 Apr 12 11:26 ./
drwxrwxr-x 20 xxx xxx 4096 Apr 12 11:31 ../
drwxr-xr-x 7 root root 4096 Apr 13 15:39 .git/

git clone git@bjgitlab.xxxi.com:golang/vodserver.git

root@ubuntu:/home/xxxa/trunk/vod# ls
vodserver

4.2 提交本地Project

 cd /d/代码/GitLab/mp4-convert

git init

git add .

git commit -m "init commit"

git remote add origin git@bjgitlab.xxx.com:tang/mp4-convet.git

git push origin master

4.3 其他操作:

查看远程地址。origin 是仓库的名字

git remote -v 
origin git@bjgitlab.xxx.com:tang/mp4-convet.git (fetch)
origin git@bjgitlab.xxx.com:tang/mp4-convet.git (push)

查看所有分支

git branch -a
* master
remotes/origin/master

切换分支

git checkout 分支名

从master合并已改的内容到新分支

git checkout 切换到新分支

git merge master

建立新分支

git checkout -b mp4dev

git push origin mp4dev

其他

git status 查看git是否又修改的内容提交

git branch 查看分支

git add filename 逐个添加文件
git add -A 添加当前目录的所有文件
git add . 添加当前目录中所有文件的更改
git commit -m "提交信息"
git push 向gitlab推动代码
git push origin master 向远处仓库推送代码

git log 显示从最近到最远的提交日志
git log --oneline 显示log 但不显示一些噪杂的信息
q 停止查看
git reflog 查看曾经使用过的命令
git reset<-hard>head 当前的add 全部消失 回到上一次commit
git reset <--hard>head^ 回到当前master的上一个commit
git reset<--hard>+commit_id 回到某个版本号的版本

回退

1.通过git log查log

tang@A120269 MINGW64 /d/代码/GitLab/vodserver/vodserver/controllers (master)
$ git log
commit f46915a67cfa88b6281182a757141c9665d1ff52 (HEAD -> master, origin/master, origin/HEAD)
Author: xxx <guohua.tang@xxx.com>
Date: Tue Mar 14 10:58:12 2023 +0800

add remove login check log

commit 2f31b3d5f89d1be982d9adf76034680e4db44ce5
Author:xxx  <xxx@xxx.com>

2. git revert 2f31b3d5f89d1be982d9adf76034680e4db44ce5

3. git push

go 1.12

require (
    github.com/KscSDK/ksc-sdk-go v0.1.44
    github.com/alibabacloud-go/cdn-20180510 v1.0.9
    github.com/alibabacloud-go/darabonba-openapi v0.1.16
    github.com/alibabacloud-go/tea v1.1.17
    github.com/alibabacloud-go/tea-utils v1.4.4
    github.com/aliyun/alibaba-cloud-sdk-go v1.61.1553
    github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible
    github.com/astaxie/beego v1.4.3
    github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
    github.com/go-sql-driver/mysql v1.5.0
    github.com/rs/xid v1.4.0
    github.com/satori/go.uuid v1.2.0 // indirect
    golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
    xxx.com/golang/core v0.0.5
)

replace (
    git.apache.org/thrift.git v0.0.1 => bjgitlab.xx.com/golang/open-source/thrift-go.git v0.0.1
    github.com/afex/hystrix-go v0.0.1 => bjgitlab.xx.com/golang/open-source/hystrix-go.git v0.0.1
    github.com/apache/thrift v0.0.1 => bjgitlab.xx.com/golang/open-source/thrift-go-sub.git v0.0.1
    github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7 => bjgitlab.xxx.com/golang/open-source/redigo.git v0.0.3
    xxx.com/golang/core v0.0.5 => bjgitlab.xxx.com/golang/core.git v1.3.3-0.20220414025643-fd587c3c8e1e
    go-agent/blueware v0.0.1 => bjgitlab.xx.com/golang/open-source/blueware.git v0.0.1
    golang.org/x/net => golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba
)

需要设置代理 GOPROXY=http://192.168.xx.xx:3000; 之前使用的代理 https://goproxy.cn 不能访问 bjgitlab.xxx.com

GOSUMDB 的全称为 Go CheckSum Database,用来对下载的包进行安全性校验,校验不通过的时候设置 GOSUMDB=off关闭校验。

使用最新版本的golib库,到core的history里面复制最新版本替换下面的 

v1.3.3-0.20220414025643-fd587c3c8e1e 然后编译,这样编译的时候使用的就是最新版本的golib

xxx.com/golang/core v0.0.5 => bjgitlab.xxx.com/golang/core.git v1.3.3-0.20220414025643-fd587c3c8e1e

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

tangcpp

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值