gitlab新建项目提交代码

 

前言

gitlab前面已经搭建好了,如果我们想用把代码上传到gitlab仓库上的话,先要新建一个项目仓库。然后本地安装git环境,就可以提交了

root用户

gitlab首次在浏览器上打开web页面,会出现设置root初始密码的界面,密码设置8位数,比如:11111111

密码设置之后,用root用户名就可以登录了

登录成功后页面

新建项目

我们在开发一个项目的时候,需要先在gitlab上新建一个工程,点加号选“New project”

项目名称随便写,项目有三个权限

  • Private 私有项目,只有自己或者项目组内的人才能访问
  • Internal 所有登录的用户都能访问
  • Public 公开的,任何人都能访问

新建成功后,把项目地址复制出来http://47.104.x.x:8100/root/jason.git

git安装

GIT不仅仅是个版本控制系统,它也是个内容管理系统(CMS),工作管理系统等。
如果你是一个具有使用SVN背景的人,你需要做一定的思想转换,来适应GIT提供的一些概念和特征。

Git 与 SVN 区别点:

  • GIT是分布式的,SVN不是:这是GIT和其它非分布式的版本控制系统,例如SVN,CVS等,最核心的区别。
  • GIT把内容按元数据方式存储,而SVN是按文件:所有的资源控制系统都是把文件的元信息隐藏在一个类似.svn,.cvs等的文件夹里。
  • GIT分支和SVN的分支不同:分支在SVN中一点不特别,就是版本库中的另外的一个目录。
  • GIT没有一个全局的版本号,而SVN有:目前为止这是跟SVN相比GIT缺少的最大的一个特征。
  • GIT的内容完整性要优于SVN:GIT的内容存储使用的是SHA-1哈希算法。这能确保代码内容的完整性,确保在遇到磁盘故障和网络问题时降低对版本库的破坏。

yum安装git

yum install -y git

查看版本号 git --version

# git --version
git version 1.8.3.1

添加配置 user.name 后面的名称随便写,user.email 后面是邮箱地址

# git config --global user.name "root"
# git config --global user.email "917207011@qq.com"
# git config --list
user.name=root
user.email=[email protected]

新建一个本地文件夹,cd进去,然后 init建仓

# mkdir /usr/local/git_code
# cd /usr/local/git_code/
[root@yoyo git_code]# git init
Initialized empty Git repository in /usr/local/git_code/.git/

在git_code目录,放需要上传的代码,比如新建一个test.py文件,随便写几行代码

[root@jason git_code]# vim test_yo.py
# 编辑python代码,写个print("hello world!")
# :wq保存退出

提交代码到本地仓库git add * (*是提交当前文件夹下全部的,也可以指定提交一个文件如:test.py)

[root@jason git_code]# git add *

查看仓库状态 git status

[root@jason git_code]# git status
# On branch master
#
# Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: test_yo.py #

代码提交到缓存区 git commit -m "描述"

[root@jason git_code]# git commit -m "add test.py"

提交到远程仓库

[root@jason git_code]# git remote add origin http://47.104.x.x:8100/root/jason.git

最后一步push推送过去,push的时候,会让你输入账号和密码,这里的用户名和密码就是gitlab上注册的用户了

[root@jason git_code]# git push -u origin master
Username for 'http://47.104.x.x:8100': root
Password for 'http://[email protected]:8100': Counting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 257 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To http://47.104.x.x:8100/root/jason.git * [new branch] master -> master Branch master set up to track remote branch master from origin. 

推送成功后,打开gitlab后台,会发现已经有一次成功的提交了

 
 

前言

gitlab前面已经搭建好了,如果我们想用把代码上传到gitlab仓库上的话,先要新建一个项目仓库。然后本地安装git环境,就可以提交了

root用户

gitlab首次在浏览器上打开web页面,会出现设置root初始密码的界面,密码设置8位数,比如:11111111

密码设置之后,用root用户名就可以登录了

登录成功后页面

新建项目

我们在开发一个项目的时候,需要先在gitlab上新建一个工程,点加号选“New project”

项目名称随便写,项目有三个权限

  • Private 私有项目,只有自己或者项目组内的人才能访问
  • Internal 所有登录的用户都能访问
  • Public 公开的,任何人都能访问

新建成功后,把项目地址复制出来http://47.104.x.x:8100/root/jason.git

git安装

GIT不仅仅是个版本控制系统,它也是个内容管理系统(CMS),工作管理系统等。
如果你是一个具有使用SVN背景的人,你需要做一定的思想转换,来适应GIT提供的一些概念和特征。

Git 与 SVN 区别点:

  • GIT是分布式的,SVN不是:这是GIT和其它非分布式的版本控制系统,例如SVN,CVS等,最核心的区别。
  • GIT把内容按元数据方式存储,而SVN是按文件:所有的资源控制系统都是把文件的元信息隐藏在一个类似.svn,.cvs等的文件夹里。
  • GIT分支和SVN的分支不同:分支在SVN中一点不特别,就是版本库中的另外的一个目录。
  • GIT没有一个全局的版本号,而SVN有:目前为止这是跟SVN相比GIT缺少的最大的一个特征。
  • GIT的内容完整性要优于SVN:GIT的内容存储使用的是SHA-1哈希算法。这能确保代码内容的完整性,确保在遇到磁盘故障和网络问题时降低对版本库的破坏。

yum安装git

yum install -y git

查看版本号 git --version

# git --version
git version 1.8.3.1

添加配置 user.name 后面的名称随便写,user.email 后面是邮箱地址

# git config --global user.name "root"
# git config --global user.email "917207011@qq.com"
# git config --list
user.name=root
user.email=[email protected]

新建一个本地文件夹,cd进去,然后 init建仓

# mkdir /usr/local/git_code
# cd /usr/local/git_code/
[root@yoyo git_code]# git init
Initialized empty Git repository in /usr/local/git_code/.git/

在git_code目录,放需要上传的代码,比如新建一个test.py文件,随便写几行代码

[root@jason git_code]# vim test_yo.py
# 编辑python代码,写个print("hello world!")
# :wq保存退出

提交代码到本地仓库git add * (*是提交当前文件夹下全部的,也可以指定提交一个文件如:test.py)

[root@jason git_code]# git add *

查看仓库状态 git status

[root@jason git_code]# git status
# On branch master
#
# Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: test_yo.py #

代码提交到缓存区 git commit -m "描述"

[root@jason git_code]# git commit -m "add test.py"

提交到远程仓库

[root@jason git_code]# git remote add origin http://47.104.x.x:8100/root/jason.git

最后一步push推送过去,push的时候,会让你输入账号和密码,这里的用户名和密码就是gitlab上注册的用户了

[root@jason git_code]# git push -u origin master
Username for 'http://47.104.x.x:8100': root
Password for 'http://[email protected]:8100': Counting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 257 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To http://47.104.x.x:8100/root/jason.git * [new branch] master -> master Branch master set up to track remote branch master from origin. 

推送成功后,打开gitlab后台,会发现已经有一次成功的提交了

猜你喜欢

转载自www.cnblogs.com/jason89/p/10327245.html