Git如何克隆Gitlab?Git本地仓库如何上传Gitlab?

简介:  首先确保本机已经安装上Git,其次确认可以正常访问Gitlab服务器 环境:  Git:Centos 7.x  192.168.126.138  Gitlab: Centos7.x 192.

 

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

 环境:

  Git:Centos 7.x  192.168.126.138

  Gitlab: Centos7.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

目录
相关文章
|
24天前
|
敏捷开发 测试技术 持续交付
阿里云云效产品使用合集之如何将个人账号下的Git仓库转移到企业账号下
云效作为一款全面覆盖研发全生命周期管理的云端效能平台,致力于帮助企业实现高效协同、敏捷研发和持续交付。本合集收集整理了用户在使用云效过程中遇到的常见问题,问题涉及项目创建与管理、需求规划与迭代、代码托管与版本控制、自动化测试、持续集成与发布等方面。
|
18天前
|
IDE 网络安全 开发工具
【Azure App Service】Local Git App Service的仓库代码遇见卡住不Clone代码的问题
【Azure App Service】Local Git App Service的仓库代码遇见卡住不Clone代码的问题
【Azure App Service】Local Git App Service的仓库代码遇见卡住不Clone代码的问题
|
15天前
|
Linux 网络安全 开发工具
码农日常生活之Git & Gitlab & Gitk
本文是关于Git和GitLab的配置使用教程,包括基础设置、日常命令操作以及图形工具的使用。
37 2
|
15天前
|
缓存 开发工具 git
给Git仓库添加.gitignore:清理、删除、排除被Git误添加的临时文件
本文介绍了如何为Git仓库添加`.gitignore`文件来排除不需要跟踪的临时文件,并展示了如何删除已经被提交的临时文件缓存,以清理Git仓库中的不必要文件。
68 0
给Git仓库添加.gitignore:清理、删除、排除被Git误添加的临时文件
|
29天前
|
存储 Java 开发工具
Git 仓库瘦身与 LFS 大文件存储
【8月更文挑战第13天】在软件开发中,Git仓库可能因累积大量数据而变得臃肿。通过删除多余分支和标签、清理无用提交,并利用`git gc`命令,可有效瘦身仓库。此外,使用Git LFS(Large File Storage)管理大文件,不仅能维持仓库精简,还能高效协作。需先安装并初始化LFS,然后跟踪特定格式的大文件。通过标准的`git add`和`git commit`命令即可管理这些文件,LFS会自动处理其存储与传输。这种方式有助于提升仓库性能与可维护性,但需注意可能产生的额外存储成本。
|
30天前
|
缓存 Shell 网络安全
Git Bash⭐二、与仓库建立连接、提交与下拉项目
Git Bash⭐二、与仓库建立连接、提交与下拉项目
|
1月前
|
jenkins 持续交付 网络安全
[jenkins]连接git仓库
[jenkins]连接git仓库
|
2月前
|
开发工具 git
git或gitee 提交代码到远程仓库
git或gitee 提交代码到远程仓库
26 2
|
30天前
|
jenkins 持续交付 数据安全/隐私保护
GitLab——如何快速部署GitLab仓库
GitLab——如何快速部署GitLab仓库
24 0
|
1月前
|
网络安全 开发工具 git
python在容器内克隆拉取git私有仓库
python在容器内克隆拉取git私有仓库