|
|
# What is Git?
|
|
|
|
|
|
Git is a version control system used to track changes in computer files. Git's primary purpose is to manage any changes made in one or more projects over a given period of time. It helps coordinate work among members of a project team and tracks progress over time.
|
|
|
|
|
|
# What is Gitlab?
|
|
|
|
|
|
GitLab is a web-based DevOps lifecycle tool that provides a Git-repository manager providing wiki, issue-tracking and continuous integration and deployment pipeline features, using an open-source license, developed by GitLab Inc.
|
|
|
|
|
|
# How to work with GitLab?
|
|
|
|
|
|
In GitLab, you use groups to manage one or more related projects at the same time.
|
|
|
|
|
|
You can use groups to manage permissions for your projects. If someone has access to the group, they get access to all the projects in the group. You can also view all of the issues and merge requests for the projects in the group, and view analytics that show the group’s activity.
|
|
|
|
|
|
For larger organizations, you can also create subgroups.
|
|
|
|
|
|
More about groups, subgroups and members at https://docs.gitlab.com/ee/topics/set_up_organization.html and https://docs.gitlab.com/ee/user/project/code_owners.html .
|
|
|
|
|
|
To view groups:
|
|
|
1\. On the top bar, select Menu > Groups.
|
|
|
2\. Select Your Groups. All groups you are a member of are displayed.
|
|
|
|
|
|
Also the same actions to see your projects.
|
|
|
|
|
|
![1](uploads/f82fb59a56d60b5ed71a144572124796/1.png)
|
|
|
|
|
|
When you open the page of your group, you can see projects (repositories) of this group or subgroup.
|
|
|
|
|
|
More about projects at https://docs.gitlab.com/ee/user/project/working_with_projects.html and at https://docs.gitlab.com/ee/user/project/repository/ .
|
|
|
|
|
|
![2](uploads/be7f5971d94baf7de0db7fc722d69ba9/2.png)
|
|
|
|
|
|
For example, here is a repository «project» in subgroup «group0».
|
|
|
|
|
|
![3](uploads/5bf1bf91cb9a1670ae512a3dc6337565/3.png)
|
|
|
|
|
|
It is your repository to publish project tasks.
|
|
|
|
|
|
There is a branch switching control in the upper-left area of the project’s webpage. Each branch can be treated as an isolated state of the project sources intended for a particular development goal.
|
|
|
|
|
|
A branch is a version of a project’s working tree. You create a branch for each set of related changes you make. This keeps each set of changes separate from each other, allowing changes to be made in parallel, without affecting each other.
|
|
|
|
|
|
For example, “master” branch typically contains production-ready state of the sources corresponding the accomplished version of the product. “develop” branch typically contains shared work-in-progress state of the sources. Other branches can be created to isolate parts of work on the project while being in process before they’ll be ready to merge into “develop” branch to be shared with other participants of the project.
|
|
|
|
|
|
Merge operations and pull-requests are used to manage and transfer modifications between branches.
|
|
|
|
|
|
More about branches at https://docs.gitlab.com/ee/user/project/repository/branches/ .
|
|
|
|
|
|
There are 2 branches here.
|
|
|
|
|
|
![4](uploads/a20a29a684c45f489c66efe6528c4477/4.png)
|
|
|
|
|
|
To see actual state of some branch your repository you should switch branch as shown in a next picture.
|
|
|
|
|
|
![5](uploads/f29e2edbfac30d309ab6df8619eece16/5.png)
|
|
|
|
|
|
To submit a file to the repository, you should press «+» button near the branches switcher and press «Upload file».
|
|
|
|
|
|
![6](uploads/3c57d472b5817b5d619d2411365d127d/6.png)
|
|
|
|
|
|
Then such a pop-up window will appear. You should choose the file you want to upload and change «Commit message».
|
|
|
|
|
|
A commit is information about modified files.
|
|
|
|
|
|
![7](uploads/6ead7df71574bb4de9d695a4561cf4fe/7.png)
|
|
|
|
|
|
After that you can press «Upload file» button and uploaded file in the repository will be opened. To return to the repository view you can press at the project’s name near the branches switcher («project» here) or in a left menu press «Repository» -> «Files» button.
|
|
|
|
|
|
![8](uploads/86f9c6730976098d500cf2caff4a8c48/8.png)
|
|
|
|
|
|
Returning to the repository view you will see that new file was added. Also information about last commit with a commit message and author is available in this view.
|
|
|
|
|
|
![9](uploads/0af0518c8c7084c976981fd41d9a6522/9.png)
|
|
|
|
|
|
To see all commits you can press «Repository» -> «Commits» button in a left menu. After that you will see a list of commits.
|
|
|
|
|
|
![10](uploads/0b11e8144a422dcf5ba8ed183a0762cb/10.png)
|
|
|
|
|
|
If you press on some commit in this list, you will see changes, which that commit made.
|
|
|
|
|
|
![11](uploads/81bdfcdb0a54da76276ed81fd16aa44f/11.png)
|
|
|
|
|
|
To see the repository state after that commit, press «Browse files» button. You can download whole repository in archive if you press Download button and choose suitable format.
|
|
|
|
|
|
![12](uploads/e4918f959ce915bcd7c14d9fb49b24eb/12.png)
|
|
|
|
|
|
In a branch switcher here you see commit identifier. When you upload all necessary files and want the teacher to check your work, press «Create merge request» button.
|
|
|
|
|
|
Merge requests are the way you check source code changes into a branch. More about merge requests at https://docs.gitlab.com/ee/user/project/merge_requests/ .
|
|
|
|
|
|
Usually according to course’s policy you need to assign your merge request to a teacher, so he could see your merge request and be able to merge it in a master branch. Choose in «Assignee» teacher in a list.
|
|
|
|
|
|
![14](uploads/08197901a1ad15f0db16de68e1c23968/14.png)
|
|
|
|
|
|
Now you see your merge request. Here could be some comments about your work from teacher. It could be a comment or a Thread as in the next picture. A Thread is a comment that should be answered by you. You will see comments and threads and be able to write your comments here to communicate with teacher.
|
|
|
About merge requests reviewing https://docs.gitlab.com/ee/user/project/merge_requests/reviews/
|
|
|
|
|
|
![15](uploads/7d98d7ec42ac60e7c4077d58b01d2e1e/15.png)
|
|
|
|
|
|
If some changes to your work needed, you should make a new commit. So, return to the «Repository» -> «Files» and choose the file where you need to make changes. Don’t forget to switch branch if it's necessary! Press «Replace» button to Upload updated file. If you want to delete file, you can press «Delete» button. In both cases new commit will be automatically created.
|
|
|
|
|
|
![16](uploads/99b50194ecad0e49b0c1299c8765679c/16.png)
|
|
|
|
|
|
And Upload updated file in a form.
|
|
|
|
|
|
![17](uploads/2d30ac0430e511e1bd93139ceb747d70/17.png)
|
|
|
|
|
|
Returning to the repository view we see our commit with replacing a file.
|
|
|
|
|
|
![18](uploads/c63b8bc4e81caa469cfb260d56664cfc/18.png)
|
|
|
|
|
|
Let’s see how our merge request changed. To see your merge requests press «Merge requests» button in a left menu.
|
|
|
|
|
|
![19](uploads/fb0a4efb78e35b2a719419594dae9890/19.png)
|
|
|
|
|
|
Choose the merge request. Now you see that new commit was added to opened merge request. You can write a comment to a thread that you made some changes and make brief explanation or answer if it's necessary.
|
|
|
|
|
|
![20](uploads/d4c360435ddc0f956f72ca7bce6a2b62/20.png)
|
|
|
|
|
|
If your work was accepted, merge request will be merged or closed according to course’s policy.
|
|
|
|
|
|
![21](uploads/02e30bed946d0a766130cdf1abc300fc/21.png)
|
|
|
|
|
|
You can edit one file together, but remember, that there could be a conflicts when you tried to commit you changes. For example, here is a conflict in merge request.
|
|
|
|
|
|
There could be a situation when GitLab couldn’t propose you to choose a solution of conflict. Here is only option to merge locally.
|
|
|
|
|
|
More about how to resolve conflicts at https://docs.gitlab.com/ee/topics/git/merge_conflicts.html and https://docs.gitlab.com/ee/user/project/merge_requests/resolve_conflicts.html .
|
|
|
|
|
|
![22](uploads/78d1634d90a1e789f674b219aa7c5038/22.png)
|
|
|
|
|
|
Similar to reverting a merge request, you can opt to revert the changes directly into the target branch or create a new merge request to revert the changes.
|
|
|
See more at https://docs.gitlab.com/ee/user/project/merge_requests/revert_changes.html .
|
|
|
|
|
|
To do it, press on commits and choose a commit.
|
|
|
|
|
|
![23](uploads/7fc2d61fab83b79e41768462e688434d/23.png)
|
|
|
|
|
|
Press «Revert» button. You will see the dialog box like presented in the next picture.
|
|
|
|
|
|
![24](uploads/669c7f4da5757315b28c53b1b20a8b17/24.png)
|
|
|
|
|
|
Press «Revert». After a commit is reverted, the «Revert» button is no longer available.
|
|
|
|
|
|
Usually you can merge pull request automatically. There is a «Resolve conflicts» button appeared.
|
|
|
|
|
|
![25](uploads/30c33b220e9c02645f934563a8924cfc/25.png)
|
|
|
|
|
|
Press «Resolve conflicts» button. You will see some editor with changes and two proposed options: *use theirs* and *use mine.* Press one of this buttons that is suitable for your situation.
|
|
|
|
|
|
![26](uploads/a58299457b3e2e9857fdb3c59c414e7b/26.png)
|
|
|
|
|
|
If you want to combine two variants of the file, choose «Edit inline» and made some changes.
|
|
|
|
|
|
![27](uploads/2bb0c6e24665acff46540f10af0dd49c/27.png)
|
|
|
|
|
|
Finally, press «Commit to source branch» button. So, commit to *develop* branch with this changes will be created. If all conflicts resolved, it will be possible to merge.
|
|
|
|
|
|
You are working in a team so you can work together in a one time but on different parts of project. Then you need different branches for work. To create new branch press «Repository» -> «Branches» button.
|
|
|
|
|
|
![28](uploads/5abadd638db1cbe08fed219ae8a54c82/28.png)
|
|
|
|
|
|
Press «New branch», write name of the branch in a form, choose another branch which should be the start state for the new one and press «Create branch» button.
|
|
|
|
|
|
![29](uploads/1e8613ba8dbda5cc6cb5438007c35747/29.png)
|
|
|
|
|
|
Another one new branch will be created.
|
|
|
|
|
|
![30](uploads/81e20c89addbef8bd0e620044d72eae7/30.png)
|
|
|
|
|
|
Be carefully with working in different branches on the same files. Divide your subtasks between the team members to work in different branches on different files to avoid conflicts.
|
|
|
|
|
|
More about working with git and git commands:
|
|
|
https://git-scm.com/book/en/v2 , https://docs.gitlab.com/ee/topics/git/ |
|
|
\ No newline at end of file |