首先确保本机已经安装上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
file changed, insertion(+)
create mode 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: , done.
Writing objects: % (/), bytes | bytes/s, done.
Total (delta ), reused (delta )
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

Git如何克隆Gitlab?Git本地仓库如何上传Gitlab?的更多相关文章

  1. git代码管理——克隆项目到本地仓库及上传本地项目到仓库

    一.克隆项目到本地仓库 1.github网站操作 1.1 登录github 首先创建一个仓库,点击“New” 1.2 输入仓库信息 1.3 创建完成后,会多出一个仓库 2.安装git客户端 2.1 安 ...

  2. (超详细)使用git命令行将本地仓库代码上传到github或gitlab远程仓库

    (超详细)使用git命令行将本地仓库代码上传到github或gitlab远程仓库 本地创建了一个 xcode 工程项目,现通过 命令行 将该项目上传到 github 或者 gitlab 远程仓库,具体 ...

  3. Eclipse中使用GIT将已提交到本地的文件上传至远程仓库

    GIT将已提交到本地的文件上传至远程仓库: 1.  右击项目——Team——Push to Upstream,即可将已保存在本地的文件上传推至GIT远程仓库.

  4. 如何使用Git建立本地仓库并上传代码到GitHub

    使用Git建立本地仓库并上传代码到GitHub 工具/原料   电脑安装git客户端.注册github账号并登陆 方法/步骤     到本地项目文件夹右键选择git bash here   输入个人信 ...

  5. [笔记]解决git本地仓库不能上传到gitee远程仓库的问题

    关键词:git.gitee.码云.上传远程仓库失败 1.gitee有一个远程仓库名字是CommandModel,里面只有两个README文件 2.假如我目录  D:\eclipse\workspace ...

  6. 把本地仓库工程上传到github上和从gitbu同步工程到本地

    1.在本地产生秘钥和公钥 [root@jacky git_project]# ssh-keygen -t rsa -C "jacky-lulu@1073740572@qq.com" ...

  7. GitHub Desktop 如何创建本地仓库,上传代码,删除仓库

    1.创建本地仓库 2.打开本地仓库,将要上传的文件放到本地仓库. 3.ctrl+p push仓库或者菜单栏Repository下push也可以用右上角的publish respository 4.左边 ...

  8. Git创建一个自己的本地仓库

    如果我们要把一个项目加入到Git的版本管理中,可以在项目所在的目录用git init命令建立一个空的本地仓库,然后再用git add命令把它们都加入到Git本地仓库的暂存区(stage or inde ...

  9. git本地项目代码上传至码云远程仓库总结【转】

    转载自 :https://blog.csdn.net/fox9916/article/details/78253714 git基本使用小结 之前公司的版本控制工具一直用的是svn,最近要改用git,之 ...

随机推荐

  1. POJ 3414:Pots

    Pots Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11661   Accepted: 4940   Special J ...

  2. javascript 总结(持续更新)

    1.jQuery对象转DOM对象. jQuery对象转DOM对象有两种方法,[index]和get(index). var $cr = $("#cr"); //jQuery对象 v ...

  3. ubuntu编译airplay

    1.alsa/asoundlib.h: No such file or directory 缺少一个库: apt-get install libasound2-dev   2.fatal error: ...

  4. python dictionary的遍历

    d = {'x':1, 'y':3, 'z':2} for k in d:    print d[k] 直接遍历k in d的话,遍历的是dictionary的keys. 2 字典的键可以是任何不可变 ...

  5. positive 相对其正常位置,那什么是正常位置: 请问调试,请问浏览器

    [问题代码 <!DOCTYPE html><html><head> <title></title> <meta charset=&qu ...

  6. MD5的学习与练习

    MD5加密的Java实现 在各种应用系统中,如果需要设置账户,那么就会涉及到存储用户账户信息的问题,为了保证所存储账户信息的安全,通常会采用MD5加密的方式来,进行存储.首先,简单得介绍一下,什么是M ...

  7. mysql字符串的常用函数(截取和拼接)

    #截取字符串(先正序取2个,再倒序取1个)SELECT SUBSTRING_INDEX(SUBSTRING_INDEX('aaa-gg-cc-dd','-',2),'-',-1) #获取子表某个字段的 ...

  8. 以太坊EVM在安全性方面的考虑

    以太坊上用户编写的合约是不可控的,要保证这些合约能够正确执行并且不会影响区块链的稳定,虚拟机需要做安全方面的考虑. 1 在程序执行过程中采取的每个计算步骤都必须提前支付费用, 从而防止DoS攻击.先消 ...

  9. java android 将 List中元素互换位置

    很多时候我要对List中的元素调换位置,这时候可以用如下代码,意思是将data中的index1与index2元素互换位置 //data 为List Collections.swap(data,inde ...

  10. hdu acm 2844 Coins 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2844 题目意思:有A1,A2,...,An 这 n 种面值的钱,分别对应的数量是C1,C2,...,C ...