Skip to main content

Experiment to Demonstrating Version Control with GitLab

 Title: Demonstrating Version Control with GitLab


Objective:

The objective of this experiment is to showcase the basic functionalities of version control using GitLab. We will create a simple project, set up a GitLab repository, and perform version control operations such as creating branches, making changes, committing changes, and merging branches.


Tools and Technologies:

  • GitLab Community Edition (CE)

  • Git (command-line or Git GUI client)

  • Web browser


Experiment Steps:

Step 1: Set Up GitLab Repository

  1. Create a new project/repository on GitLab.

  2. Clone the repository to your local development environment using Git.

Step 2: Initialize the Project

  1. Create a new directory for the project on your local machine.

  2. Initialize a Git repository in this directory using the command: git init.

Step 3: Configure Git Remote

  1. Set the GitLab repository as the remote for your local repository using the command: git remote add origin <GitLab_Repository_URL>.

Step 4: Create and Switch Branches

  1. Create a new branch called "feature-branch" using the command: git checkout -b feature-branch.

  2. Switch back to the main branch (usually "master" or "main") using: git checkout main.

Step 5: Make Changes and Commit

  1. Create a new file or modify an existing one in your project directory.

  2. Add the changes to the staging area using: git add <file_name>.

  3. Commit the changes with a descriptive message using: git commit -m "Your commit message".

Step 6: Push Changes to GitLab

  1. Push the committed changes to the GitLab repository using: git push origin <branch_name> (e.g., git push origin main).

Step 7: Merge Branches

  1. Switch to the main branch using: git checkout main.

  2. Merge the "feature-branch" into the main branch using: git merge feature-branch.

  3. Resolve any merge conflicts if they occur.

  4. Commit the merge changes and push them to the GitLab repository.

Step 8: Review History

  1. View the commit history using: git log.

  2. Use GitLab's web interface to visualize the commit history, branches, and merge requests.

Step 9: Optional - Collaborate with Others

  1. Invite collaborators to your GitLab repository.

  2. Ask collaborators to clone the repository, make changes, and push them to GitLab.

  3. Review and merge their changes using merge requests.

Conclusion:

This experiment demonstrates the fundamental version control operations using GitLab. By following these steps, you have gained an understanding of how to set up a repository, create branches, make changes, commit changes, merge branches, and collaborate with others using GitLab's version control capabilities. Version control plays a crucial role in enabling teams to collaborate efficiently and manage changes in software development projects effectively.

Comments

Popular posts from this blog

Example of Maven project that interacts with a MySQL database and includes testing

Example Maven project that interacts with a MySQL database and includes testing To install Java, MySQL, Maven, and write a Java program to fetch table data, execute, and create a JAR file using Maven on Ubuntu, you can follow these steps: Step 1: Install Java You can install Java using the following commands: sudo apt update sudo apt install default-jre sudo apt install default-jdk Verify the installation by running: java -version Step 2: Install MySQL You can install MySQL using the following commands: sudo apt update sudo apt install mysql-server During the installation, you'll be prompted to set a root password for MySQL or you can set password at latter stage using following steps.  sudo mysql ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; exit Step 3: Install Maven You can install Maven using the following commands: sudo apt update sudo apt install maven Verify the installation by running: mvn -version Step 4: Create

Maven Create and Build Artifacts

In Maven, you can create and build artifacts using the package phase of the build lifecycle. The package phase is responsible for taking the compiled code and other project resources and packaging them into a distributable format, such as a JAR (Java Archive), WAR (Web Application Archive), or other custom formats. Here are the steps to create and build artifacts using Maven: Configure the Build Output: In your project's pom.xml file, you need to configure the output of the build. This includes specifying the type of artifact you want to create (e.g., JAR, WAR) and any additional resources to include. You do this in the <build> section of your pom.xml: <build>     <finalName>my-artifact</finalName> <!-- Name of the artifact without the extension -->     <plugins>         <!-- Plugin configurations for creating the artifact -->         <!-- For example, maven-jar-plugin or maven-war-plugin -->     </plugins> </build> Depend

Maven Repositories (local, central, global)

Maven relies on repositories to manage dependencies, plugins, and other artifacts required for a project. There are typically three types of repositories in Maven: local, central, and remote/global repositories. Local Repository: Location: The local repository is located on your local development machine. By default, it's in the .m2 directory within your user home directory (e.g., C:\Users\<username>\.m2\repository on Windows or /Users/<username>/.m2/repository on macOS and Linux). Purpose: The local repository is used to store artifacts (JARs, POMs, and other files) that your machine has downloaded or built during previous Maven builds. These artifacts are specific to your local development environment. Benefits: Using a local repository improves build performance since it caches dependencies locally, reducing the need to download them repeatedly. It also ensures reproducibility by maintaining a local copy of dependencies. Central Repository: Location: The central repo