> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# APPENDIX C Pre Requisite SCM

> Introduction to source code management, Git basics, merging, repository structure, and how SCM enables reproducible builds, CI/CD pipelines, and reliable deployments for beginners.

Hello, and welcome to this lesson on source code management (SCM) and builds.

This appendix introduces the fundamentals of SCM, builds, pipelines, and how they enable reliable deployments. It’s written for beginners with no prior experience — if you already understand SCM basics, feel free to skip ahead to the hands-on sections that apply these concepts to specific platforms.

<Callout icon="lightbulb" color="#1CB2FE">
  If you’re short on time: focus on the concepts and the Git quick-start later in this doc. These fundamentals are what enable building automated pipelines and repeatable releases.
</Callout>

## Why source code management matters

Modern applications are often composed of multiple components maintained by different teams:

| Component | Typical responsibilities / technologies |
| - | - |
| Front-end | HTML5, CSS, JavaScript frameworks (React, Angular, Vue) |
| Back-end | Python, Java, Node.js, microservices |
| Database & integration | Schema design, connectors, API integrations |

When many developers work on the same codebase — sometimes editing the same files — you need a system to coordinate changes, keep a history, and manage versions across development, staging, and production. That system is SCM (also called version control or revision control).

## What an SCM system provides

An SCM system solves collaboration and auditability problems by:

* Storing source code in centralized or distributed repositories (on-prem or cloud).
* Tracking changes over time with metadata (who changed what and when).
* Allowing multiple contributors to work concurrently and merging changes.
* Flagging merge conflicts when edits overlap and cannot be auto-merged.
* Providing history, review workflows, and analytics for releases.

You can summarize core SCM capabilities in a single view:

| Feature | Why it matters |
| - | - |
| Commit history | Understand changes, rollback if needed |
| Branching & merging | Isolate features and merge when ready |
| Access control | Enforce permissions and secure code |
| Pull/Merge requests | Review and discuss changes before merging |
| Auditability & metrics | Track contribution, churn, and release readiness |

## Example repository layout

A typical web application repository might use a structure like this:

```text theme={null}
|-- README.md
|-- Dockerfile
|-- bower.json
|-- package.json
|-- app
    |-- app.js
    |-- web
        |-- index.html
        |-- mddir.js
        |-- routing.js
        |-- server.js
    |-- api
        |-- api.groups.js
        |-- api.posts.js
        |-- api.users.js
        |-- api.widgets.js
        |-- authentication
            |-- oauth.js
            |-- vendor
    |-- database
        |-- db.js
    |-- integration
        |-- servicenow.js
```

Host repositories on platforms such as [GitHub](https://github.com), [GitLab](https://gitlab.com), or [Bitbucket](https://bitbucket.org). These platforms add access control, web-based code review, issue tracking, and CI/CD integrations.

## How merging works (and resolving conflicts)

When multiple developers modify the same codebase, the SCM attempts to merge changes automatically by comparing edits line-by-line. If two changes touch the same lines in incompatible ways, the system flags a merge conflict and requires manual resolution.

Here is a small example showing how a diff/patch might look when merging changes from two contributors:

```diff theme={null}
1  client/app/main/main.html
@@ -18,6 +18,7 @@
<div class="container">

    <div class="row" style="margin-top: 10px;">
+    <div class="col-md-3"></div>
    <div class="col-md-2" style="text-align: center" ng-repeat="video in $ctrl.videos">
        <a href="" ng-click="$ctrl.showVideoModal(video)" style="color: grey">
            <div style="color: #d9534f">

2  server/config/environment/shared.js
@@ -37,7 +37,7 @@ exports = module.exports = {
{
    title: 'Overview',
    type: 'overview',
-   video_id: '6sE0Gqcw_4U'
+   video_id: 'e1o8vR5G6n4'
},
{
    title: 'Getting Started',
```

If a conflict is detected, you will be required to open the affected file(s), inspect both changes, and decide the correct final content. After editing, mark the conflict resolved and commit the result.

<Callout icon="warning" color="#FF6B6B">
  Always pull the latest changes from the mainline branch before starting significant work. Frequent merges reduce the risk and complexity of conflicts, and ensure your feature branch integrates smoothly.
</Callout>

## Benefits of building on top of SCM

A well-structured repository and disciplined SCM practices enable:

* Reproducible builds and automated tests (CI).
* Consistent pipelines for staging and production (CD).
* Controlled rollout strategies (feature flags, canary releases).
* Audit trails and compliance-ready change history.
* Better code reviews and improved software quality.

## Quick Git demo (local setup using GitLab)

Below are concise steps to get a local Git workspace connected to a GitLab repository. We’ll use this repo later when configuring builds and pipelines.

1. Create a repository in GitLab (via the web UI).
2. Clone the repository locally:

```bash theme={null}
git clone git@gitlab.com:<your-username>/<your-repo>.git
cd <your-repo>
```

3. Create and switch to a feature branch:

```bash theme={null}
git checkout -b feature/my-new-feature
```

4. Make changes, stage, and commit:

```bash theme={null}
git add .
git commit -m "Implement new feature X"
```

5. Push the branch to GitLab:

```bash theme={null}
git push --set-upstream origin feature/my-new-feature
```

6. Open a Merge Request (MR) in GitLab to request review and merge into the main branch.
7. After MR approval, merge and pull the latest main to your local workspace:

```bash theme={null}
git checkout main
git pull origin main
```

These simple commands are the foundation for integrating CI/CD pipelines that will build, test, and deploy your application automatically.

## Links and references

* [GitLab](https://gitlab.com) — hosting, merge requests, CI/CD
* [GitHub](https://github.com) — popular remote hosting and collaboration
* [Bitbucket](https://bitbucket.org) — repository hosting with pipeline support
* [Git documentation](https://git-scm.com/doc) — reference for Git commands and workflows

Let’s go through a demo of setting up a local Git environment using GitLab. We will later use this repository when we set up builds and pipelines in the hands-on exercises.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/openshift-3-for-the-absolute-beginners/module/459c09b9-e158-467d-804e-ec708a55d72f/lesson/3d195f84-734e-499b-8f11-2ae900e9e25b" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.