gitlab使用

使用命令行操作gitlab,有些理解不到位,走过路过看到的欢迎指出~~~

官方文档:https://docs.gitlab.com/ee/gitlab-basics/start-using-git.html

1. 安装gitbash(windows)和git

gitbash下载地址:https://gitforwindows.org/

检查是否安装了git,在gitbash中输入 git --version

如果没有git的版本信息,则说明未安装git,可通过该文档查看如何安装git:https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

2. 设置username和email

git config --global user.name "YOUR_USERNAME"  
git config --global user.email "your_email_address@example.com" 

确认设置的username和email

git config --global user.name
git config --global user.email

或者使用

git config --global --list

3. 把代码库下载到本地

clone with https

git clone https://gitlab.com/gitlab-org/gitlab-ce.git

clone with ssh

git clone git@gitlab.com:gitlab-org/gitlab-ce.git

4. 把本地代码push到远程

touch README.md
git add README.md
git commit -m 'add README'
git push -u origin master

push的时候我使用的用户是developer权限的,死活不成功。后来想起来master branch是protected的,把用户权限切换到Maintainer,果然成功了。

5.切换branch

git branch
git checkout xx

 切换了branch之后,我的developer权限用户终于可以正常work了。

posted @ 2019-02-28 21:52  lemontree-m  阅读(261)  评论(0)    收藏  举报