:mega: In this section, you will learn the basics about Git and how to collaborate with others using Git.
## :golf: Goal
> Our objective is to raise PR/MR (Pull Request / Merge Request) for the mentor to review your code
### :capital_abcd: Introduction
**What is Git?**
Git is a _Version-Control System_ for tracking changes in computer files and coordinating work on those files among multiple people. \
\
Git is a Distributed Version Control System. So Git does not necessarily rely on a central server to store all the versions of a project’s files. Instead, every user “clones” a copy of a repository (a collection of files) and has the full history of the project on their own hard drive. This clone has all of the metadata of the original while the original itself is stored on a self-hosted server or a third-party hosting service like GitHub.
**Advantages of Git**
* Git helps you **keep track of the changes you made** to your code. It is based on the history tab for your code editor. If you hit a fatal error and don’t know what’s causing it while coding, you can always revert it to the stable state with git. So it is very helpful for debugging. You can also see the changes you made to your code over time.
* Git also helps you **synchronize code between multiple people.** \
Imagine you and your friend are collaborating on a project. You both are working on the same project files. Now Git takes those changes you and your friend made independently and merges them to a single “Master” repository. Git makes sure you both are working on the most recent version of the repository. Therefore, you don’t have to worry about mailing your files to each other and working with a ridiculous number of copies of the original file.
**Git Workflow**
Before we start working with Git commands, you must understand what it represents.
What is a Repository? A repository, aka repo, is nothing but a collection of source code.
There are _four fundamental elements_ in the Git Workflow.
* Working Directory
* Staging Area
* Local Repository
* Remote Repository
**Diagram of a simple Git Workflow** 
### :construction_worker: Task
1. create a branch in local (branch name reference: `feature/yourname`)
2. commit all the code you modified/created in the previous sections (Item Type, DAO ...)
3. push your code to remote
4. raise PR/MR (Pull Request / Merge Request)
**How to create a merge request on Git Lab?**
1. Navigate to <https://gitlab.com/seidor-cx/sap-commerce-training>
2. Click `Merge requests` on the sidebar.\

3. Click `New merge request`\

4. Select the branch you created on `Source branch`, select the main branch on `Target branch`\
this means your branch is ready to merge into the main branch

### :children_crossing: Hints
You can use the commands below to finish these tasks.
- `git branch`
- `git checkout`
- `git add`
- `git commit`
- `git push`
- `git fetch`
- `git merge`
- `git pull`
## :white_check_mark: Check your work
> :bell: Make sure all the code you are about to push is correct. This is very important. It will cause problems for your collaborators if your code needs to be fixed.
1. You will see all of your merge requests are displayed on the **Open** tab.\

2. Click **Merge requests** , you can see that all the commits and changes are up here :point_down: 
3. Review all your changes again before notifying your mentor to review.
## :book: Additional resources
Head to [Learn Git Branching](https://learngitbranching.js.org/) or [Oh My Git!](https://ohmygit.org/) to know more about git!
---
:arrow_right: Continue with [Step 9: Groovy Scripting](/Learning-Journey/Groovy-Scripting)