上传、更新
1.git config --global user.name "c" //配置用户名
2.git config --global user.email "1@asi.com" //配置邮箱
3. ssh-keygen -t rsa -C "ci@a.com" //本地生成密钥
4. 登录gitlab,自己的账户,setting中添加生成的密钥
5 git init //初始化仓库
git clone git@22.com //克隆远程仓库所有文件到本地,类似svn的checkout
git remote //查看你已经配置的远程仓库服务器,
它会列出你指定的每一个远程服务器的简写。 如果你已经克隆了自己的仓库,那么至少应该能看到 origin - 这是 Git 给你克隆的仓库服务器的默认名字:
eg:
$ git remote
origin
$ git clone https://github.com/schacon/ticgit
git remote add <shortname> <url>
添加一个新的远程 Git 仓库,同时指定一个你可以轻松引用的简写:
6 git remote add origin git@10.23.0.38:co/testproject.git //关联远程仓库
git remote -v //查看
git fetch origin(仓库名) master(分支名)//获取远程仓库文件 推荐使用这个命令更新文件
git pull origin master //获取远程仓库文件 相当于git fetch + git merge
7.git status //查看分支状态
8 git branch -a//查看当前分支
git checkout master //切换分支
git checkout -b master //创建分支,并切换
9 git add <file> //添加文件到服务器,类似svn的add
10 git commit -m "注释内容" //提交到本地仓库
11 git push -u origin 分支名称 //将分支推到git服务器上面
问题:
1.上传失败 报“! [remote rejected] master -> master (pre-receive hook declined)”
原因:所push的分支权限为protected,只有项目的管理员或者项目的管理员指派的具有相应权限的人才能进行push,要进行项目的push,有如下两种方法:
解决方法:
1.将所要push的内容所在的分支的protected权限关闭
(1)进入所在项目的settings
(2)点击进入Protected branches,点击unprotected将master分支的权限改变,即关闭master的protected权限
2.新建其它分支,将项目push到新建的分支上,后期再进行merge
(1)新建分支
git branch 分支名
(2)切换分支
git checkout 分支名
(3)进行项目上传
git add .
git commit -m "提交的信息"
git remote add origin 远程仓库地址
git push -u origin 分支名
删除本地分支:
git branch -d 分支名
删除远程分支
git push origin --delete 分支名
将A合并到当前分支
git merge A
git已经删除了远程分支,本地仍然能看到
使用 git branch -a 命令可以查看所有本地分支和远程分支,发现很多在远程仓库已经删除的分支在本地依然可以看到。
使用命令 git remote show origin,可以查看remote地址,远程分支,还有本地分支与之相对应关系等信息。
此时我们可以看到那些远程仓库已经不存在的分支,根据提示,使用 git remote prune origin 命令:
这样就删除本地那些远程仓库不存在的分支
Project members permissions
Note: In GitLab 11.0, the Master role was renamed to Maintainer.
The following table depicts the various user permission levels in a project.
Action | Guest | Reporter | Developer | Maintainer | Owner |
---|---|---|---|---|---|
Create new issue | ✓ 1 | ✓ | ✓ | ✓ | ✓ |
Create confidential issue | ✓ 1 | ✓ | ✓ | ✓ | ✓ |
View confidential issues | (✓) 2 | ✓ | ✓ | ✓ | ✓ |
Leave comments | ✓ 1 | ✓ | ✓ | ✓ | ✓ |
See related issues | ✓ | ✓ | ✓ | ✓ | ✓ |
See a list of jobs | ✓ 3 | ✓ | ✓ | ✓ | ✓ |
See a job log | ✓ 3 | ✓ | ✓ | ✓ | ✓ |
Download and browse job artifacts | ✓ 3 | ✓ | ✓ | ✓ | ✓ |
View wiki pages | ✓ 1 | ✓ | ✓ | ✓ | ✓ |
View license management reports | ✓ 1 | ✓ | ✓ | ✓ | ✓ |
View Security reports | ✓ 1 | ✓ | ✓ | ✓ | ✓ |
View project code | 1 | ✓ | ✓ | ✓ | ✓ |
Pull project code | 1 | ✓ | ✓ | ✓ | ✓ |
Download project | 1 | ✓ | ✓ | ✓ | ✓ |
Assign issues | ✓ | ✓ | ✓ | ✓ | |
Assign merge requests | ✓ | ✓ | ✓ | ||
Label issues | ✓ | ✓ | ✓ | ✓ | |
Label merge requests | ✓ | ✓ | ✓ | ||
Create code snippets | ✓ | ✓ | ✓ | ✓ | |
Manage issue tracker | ✓ | ✓ | ✓ | ✓ | |
Manage labels | ✓ | ✓ | ✓ | ✓ | |
See a commit status | ✓ | ✓ | ✓ | ✓ | |
See a container registry | ✓ | ✓ | ✓ | ✓ | |
See environments | ✓ | ✓ | ✓ | ✓ | |
See a list of merge requests | ✓ | ✓ | ✓ | ✓ | |
Manage related issues | ✓ | ✓ | ✓ | ✓ | |
Lock issue discussions | ✓ | ✓ | ✓ | ✓ | |
Create issue from vulnerability | ✓ | ✓ | ✓ | ✓ | |
View Error Tracking list | ✓ | ✓ | ✓ | ✓ | |
Pull from Maven repository or NPM registry | ✓ | ✓ | ✓ | ✓ | |
Publish to Maven repository or NPM registry | ✓ | ✓ | ✓ | ||
Lock merge request discussions | ✓ | ✓ | ✓ | ||
Create new environments | ✓ | ✓ | ✓ | ||
Stop environments | ✓ | ✓ | ✓ | ||
Manage/Accept merge requests | ✓ | ✓ | ✓ | ||
Create new merge request | ✓ | ✓ | ✓ | ||
Create new branches | ✓ | ✓ | ✓ | ||
Push to non-protected branches | ✓ | ✓ | ✓ | ||
Force push to non-protected branches | ✓ | ✓ | ✓ | ||
Remove non-protected branches | ✓ | ✓ | ✓ | ||
Add tags | ✓ | ✓ | ✓ | ||
Write a wiki | ✓ | ✓ | ✓ | ||
Cancel and retry jobs | ✓ | ✓ | ✓ | ||
Create or update commit status | ✓ | ✓ | ✓ | ||
Update a container registry | ✓ | ✓ | ✓ | ||
Remove a container registry image | ✓ | ✓ | ✓ | ||
Create/edit/delete project milestones | ✓ | ✓ | ✓ | ||
View approved/blacklisted licenses | ✓ | ✓ | ✓ | ✓ | ✓ |
Use security dashboard | ✓ | ✓ | ✓ | ||
Dismiss vulnerability | ✓ | ✓ | ✓ | ||
Apply code change suggestions | ✓ | ✓ | ✓ | ||
Use environment terminals | ✓ | ✓ | |||
Run Web IDE’s Interactive Web Terminals | ✓ | ✓ | |||
Add new team members | ✓ | ✓ | |||
Push to protected branches | ✓ | ✓ | |||
Enable/disable branch protection | ✓ | ✓ | |||
Turn on/off protected branch push for devs | ✓ | ✓ | |||
Enable/disable tag protections | ✓ | ✓ | |||
Rewrite/remove Git tags | ✓ | ✓ | |||
Edit project | ✓ | ✓ | |||
Add deploy keys to project | ✓ | ✓ | |||
Configure project hooks | ✓ | ✓ | |||
Manage Runners | ✓ | ✓ | |||
Manage job triggers | ✓ | ✓ | |||
Manage variables | ✓ | ✓ | |||
Manage GitLab Pages | ✓ | ✓ | |||
Manage GitLab Pages domains and certificates | ✓ | ✓ | |||
Remove GitLab Pages | ✓ | ✓ | |||
View GitLab Pages protected by access control | ✓ | ✓ | ✓ | ✓ | ✓ |
Manage clusters | ✓ | ✓ | |||
Manage license policy | ✓ | ✓ | |||
Edit comments (posted by any user) | ✓ | ✓ | |||
Manage Error Tracking | ✓ | ✓ | |||
Switch visibility level | ✓ | ||||
Transfer project to another namespace | ✓ | ||||
Remove project | ✓ | ||||
Delete issues | ✓ | ||||
Force push to protected branches 4 | |||||
Remove protected branches 4 | |||||
View project Audit Events | ✓ | ✓ | |||
View project statistics | ✓ | ✓ |