Copperbelt University
School of Information Communication and Technology
Software Development (CS 130)
Developer Collaboration and Source Code Management
Understanding the Need for Developer Collaboration and Source Code
Management Platforms
In modern software development, collaboration among developers and efficient management of
source code are critical for building high-quality applications. Developer collaboration and
source code management (SCM) platforms address these needs by providing tools and
workflows that streamline coding, testing, and deployment processes.
1. The Importance of Developer Collaboration
Software development is rarely a solo effort. Most projects involve teams of developers working
together on different aspects of an application. Effective collaboration ensures:
• Code Consistency: By following shared coding standards and guidelines, teams can
maintain readability and reduce errors.
• Faster Development Cycles: Parallel development allows multiple contributors to work
on different features simultaneously.
• Efficient Issue Resolution: With shared knowledge, teams can quickly identify and
resolve bugs or vulnerabilities.
• Better Knowledge Sharing: Collaboration platforms allow developers to document and
share insights, reducing onboarding time for new team members.
2. The Role of Source Code Management (SCM)
SCM platforms are essential for tracking code changes, maintaining version history, and
managing contributions from multiple developers. These platforms provide:
• Version Control: Ensures that every change is recorded, allowing developers to revert to
previous versions when necessary.
• Branching and Merging: Developers can work on separate branches, test features
independently, and merge them seamlessly into the main codebase.
• Conflict Resolution: When multiple developers modify the same code, SCM tools help
resolve conflicts efficiently.
• Code Review and Collaboration: Team members can review each other’s code, suggest
improvements, and maintain high coding standards.
3. Popular Developer Collaboration and SCM Platforms
Several platforms facilitate collaboration and source code management, including:
• GitHub: A widely used platform that supports open-source and private repositories,
offering features like pull requests and issue tracking.
• GitLab: Provides integrated CI/CD pipelines, security testing, and DevOps tools for
seamless collaboration.
• Bitbucket: Designed for teams using Git and Mercurial, offering tight integration with
Jira and other Atlassian products.
4. Benefits of Using These Platforms
By utilizing collaboration and SCM platforms, developers and organizations can:
• Improve productivity through automated workflows.
• Enhance security with access control and audit logs.
• Ensure code quality through peer reviews and continuous integration.
• Reduce risk by tracking every change and enabling rollbacks.
Git and Github
What is Git?
Git is a distributed version control system. It helps track changes in files and coordinates
collaboration between multiple developers. Instead of manually keeping track of different versions
of files, Git allows you to track all changes automatically, revert to earlier versions, and collaborate
on the same files without overwriting each other's work.
What is Github?
GitHub is a cloud-based hosting service for Git repositories. It provides a web-based platform
where developers can store, share, and collaborate on projects using Git.
How Git and GitHub Work Together
1. Git tracks changes locally on your computer.
2. GitHub provides a central place to store those changes online so multiple developers can
access and collaborate.
3. Developers use Git commands to push (upload) and pull (download) changes between
their local computers and GitHub.
Getting Started
1. Visit github and sign up for an account ( https://github.com )
2. Visit the git and download a suitable git install either 32bit or 64bit version depending on
your windows PC ( https://git-scm.com/downloads/win ) , once downloaded install using
recommended options and for Mac users download the git installer for MacOS.
3. Open command prompt (cmd) and run the following commands – git config –global
user.name “ your name” and then run – git config --global user.email “your email
address”
Git Concepts and Commands
1.Setting up Git for your project (git init)
The command git init, initializes a new Git repository in the current folder, turning that folder into
a Git-controlled project. It sets up the necessary metadata and configuration files that Git will use
to track changes in your files. Without initializing a Git repository, Git won’t be able to track your
files. This command should always be run when you start a new project.
When to use it
Run git init only once at the start of a project.
Example
You’ve just created a folder for your website project.
Run git init to start version control in that folder.
mkdir website-project
cd website-project
git init
2. Staging ( git add . )
Stages the file(s) in preparation for committing to the repository. Git keeps track of changes to
files, but until you tell it to stage those changes with git add, it won't include those changes in the
next commit. This is a crucial step because Git doesn’t automatically assume you want to save
every change. You may make a lot of edits but not want to commit all of them at once. git add
gives you the flexibility to select which changes are part of your next commit.
When to use it
Use git add after editing files and before committing those changes to Git. You can add files one
at a time or add all changed files with git add .
Example
• You just created the index.html file for the homepage of your website.
• You want to track this change, so you run - git add index.html
• If you have multiple files modified (like about.html, contact.html, etc.), you can use git
add . to stage all the changes at once - git add .
3. Committing Changes ( git commit)
Commits the staged changes to your local Git repository, recording the snapshot of the files as they
are at that moment. The -m flag is used to provide a commit message that describes the change
made. A commit is like a "save point" in your project. It marks a specific point in the development
process. The commit message should briefly describe what has been changed, so that anyone
(including you) can review the history later and understand what was done.
When to use it
Commit after staging changes (with git add). Each commit should represent a logical change in
your project. For example, after creating index.html, you should commit those changes.
Example
• After staging the file index.html (or multiple files with git add .), you make a commit:
git commit -m "Add homepage (index.html)"
4. Understanding the Concept Repositories in Git & Github
What is a Repository?
A repository (repo) is a storage location where Git tracks and manages all the files, folders, and
history of a project. It contains:
• Project files (HTML, CSS, JavaScript, etc.)
• Commit history (record of changes made over time)
• Branches (different versions of the project for new features or fixes)
• Staged and committed changes
Types of Repositories
• Local Repository – A repository stored on your computer. (Created using git init)
• Remote Repository – A repository hosted on a service like GitHub (Created on GitHub
and linked to your local repository).
Creating a Remote Repository on GitHub
1. Sign in on github and click to the repositories tab.
2. Click the New button
3. Give your repo a name and click the create repository button
What happens is that a new repo is created on github, but its empty. In addition git will provides
instructions to link this remote repo to your local one.
How to link a local repo to a github repo
1. git remote add origin https://github.com/stephen-tembo-dev/demo.git
2. git branch -M main
3. git push -u origin
Note: You may be required to login to github, this is for github to whitelist your device.
How to clone a repo ( git clone repo-url )
Creates a copy of the entire remote repository on your local machine. This includes all the project’s
files, branches, and history. git clone is how you initially download a project to start working on it
locally. If you’re collaborating on a project, everyone will need to clone the project repository
before they start working on it.
When to use it
Use git clone when you first join a project to get a copy of the repository. If the project is already
on GitHub, you can use the GitHub URL to clone it.
Example
• If your GitHub repository is https://github.com/username/website-project, run:
git clone https://github.com/username/website-project.git
5. Pushing Changes to Github
Pushes your local commits to the remote GitHub repository. The origin refers to the remote
repository, and main is the branch where your changes are being pushed. This step uploads your
commits to GitHub, making them accessible to others and allowing collaboration. It’s important
for synchronizing your local changes with the central version of the project.
When to use it
After committing changes locally, use git push to upload those changes to the central repository,
so others can see your work.
Example
• After committing the changes to index.html, push the changes to GitHub:
git push origin main
6. Creating Branches
git branch <branch-name> creates a new branch. git checkout <branch-name> switches
to that branch, allowing you to work on separate features without affecting main branch.
Branches allow you to work on features or fixes in isolation. If you’re collaborating, you can work
on different tasks without worrying about conflicting with others. The main branch should always
contain stable, working code.
When to use it
• Use git branch to create a new branch for a specific task, and then git checkout to start
working in that branch.
• After completing a task on a branch, you can merge it back into main.
Example
• To add a new "About" page (about.html), create and switch to a branch:
git checkout -b add-about-page
7. Pulling Latest Changes
Fetches the latest changes from the remote repository (GitHub) and merges them into your local
copy. This ensures that your local project is up to date with the changes others may have made. If
you’re collaborating with others, git pull ensures that you’re working with the most recent version
of the project before you start making changes. Failing to pull frequently can lead to conflicts when
merging.
When to use it
Before starting your work each day (or whenever you want to make sure you have the latest
version). It’s also used after others have pushed changes.
Example:
• Before starting to work on a new page, pull the latest changes from GitHub:
git pull origin main
8. Creating and Merging Pull Requests (on GitHub)
Once your branch (e.g., add-about-page) is complete, you create a pull request on GitHub to
propose merging your changes into the main branch. Pull requests allow other collaborators to
review and discuss your changes before they become part of the main codebase. This process
ensures better code quality and reduces errors.
When to use it
Once you have finished working on a feature in your branch and are ready to merge it into the
main branch.
Example
• Go to GitHub, open your repository, and you’ll see a button to create a pull request for
your branch (add-about-page). Provide a description and submit the pull request.
Feature Branch Workflow
The Feature Branch Workflow is a simple yet effective Git workflow for small teams, ensuring
smooth collaboration while keeping the main branch stable. Each new feature or bug fix is
developed in a separate branch, allowing developers to work independently without disrupting the
production-ready main branch. Once a feature is complete, the developer pushes their branch to
GitHub and opens a pull request (PR) for review. Other team members can review the changes,
suggest improvements, and approve the merge. Once merged, the feature branch is deleted, and all
developers sync their local repositories to stay updated.
This approach prevents conflicts, maintains a clean and stable codebase, and enables structured
collaboration. It also allows easy rollbacks if a feature causes issues. By following this workflow,
small teams can efficiently manage their code, review changes systematically, and ensure a smooth
development process.
Figure 1 - Feature branch workflow example