感谢支持
我们一直在努力

Git克隆GitLab以及Git本地仓库上传GitLab

首先确保本机已经安装上Git,其次确认可以正常访问Gitlab服务器

 环境:

  Git:CentOS 7.x  192.168.126.138

  Gitlab: CentOS 7.x 192.168.126.137

 1:填写Gitlabn仓库信息

  登陆到Gitlab服务器地址,新建仓库

创建成功后会自动跳转至该仓库的页面:

上面红色框内,是仓库地址,我们尝试把仓库克隆到本地仓库:

[root@localhost 123]#git clone http://192.168.126.137/root/Accommate.git  #192.168.126.137是指Gitlab服务器地址,可以修改成域名,看自己爱好

  Cloning into ‘Accommate’…
  Username for ‘http://192.168.126.137’: root    #Gitlab  账号
  Password for ‘http://root@192.168.126.137’:    #Gitlab  密码
  warning: You appear to have cloned an empty repository.

将该Gitlab版本仓库添加到本机的远程列表中:

[root@localhost Accommate]# git remote add Accommate git@192.168.126.137:root/Accommate.git
[root@localhost Accommate]# git remote
Accommate
goodboys
origin

编写一个新文件:

[root@localhost /]# cd Accommate/
[root@localhost Accommate]# echo "This is Test txt - Accommate" > accommate

将该文件提交到本地的Git版本仓库:

[root@localhost Accommate]# git add accommate 
[root@localhost Accommate]# git commit -m "add accommate"
[master (root-commit) 743413d] add accommate
 1 file changed, 1 insertion(+)
 create mode 100644 accommate

然后将本地的Git仓库同步到远程Git服务器上(第一次请加上参数-u,代表关联本地与远程):

[root@localhost Accommate]# git push -u origin master
Username for 'http://192.168.126.137': root    #Gitlab 账号
Password for 'http://root@192.168.126.137':    #Gitlab 密码
Counting objects: 3, done.
Writing objects: 100% (3/3), 238 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://192.168.126.137/root/Accommate.git    #上传的仓库
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

查看下Web端的Accommate:

(上传文件前)

(上传文件后)刷新下web页面:

 查看下是不是我们之前写的内容:

 注:如果上传至Github,需要定义SSH-Key

本文永久更新链接地址:https://www.linuxidc.com/Linux/2019-02/157101.htm

赞(0) 打赏
转载请注明出处:服务器评测 » Git克隆GitLab以及Git本地仓库上传GitLab
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏