DEV Community

Pranav Bakare
Pranav Bakare

Posted on

Step-by-step guide of Gitlab flow

Step-by-step guide with descriptions for each command, starting with the flow explanation:

Basic Description of the Flow

The process of making changes to a GitLab repository follows these steps:

  1. Pull the latest code to ensure you're working on the most updated version.

  2. Create a new branch to isolate your changes from the main codebase.

  3. Make and test your changes locally.

  4. Push the changes to the remote repository.

  5. Submit a Merge Request (MR) for review and integration into the main branch.


Steps and Commands with Descriptions

  1. Clone the Repository (if not already done):

This command copies the repository from GitLab to your local machine.

git clone
cd

  1. Pull the Latest Changes:

Ensures your local branch is updated with the latest changes from the remote repository, avoiding conflicts later.

git pull origin

  1. Create a New Feature Branch:

A new branch isolates your changes from the main or develop branch, preventing accidental updates to the stable codebase.

git checkout -b

  1. Make Changes to the Code:

Edit files using your preferred IDE or editor. This is where you implement your new feature, bug fix, or other changes.

  1. Stage the Changes:

Add the modified files to the staging area, preparing them for a commit.

git add # To add specific files
git add . # To add all changes

  1. Commit the Changes:

Record your changes locally with a clear, descriptive message about what you’ve done.

git commit -m "Your descriptive commit message"

  1. Push the Feature Branch to GitLab:

Upload your branch and changes to the remote repository so others can access it.

git push origin

  1. Create a Merge Request (MR):

Navigate to GitLab in your browser.

Go to Merge Requests > New Merge Request.

Select your feature branch and the target branch (e.g., main or develop).

Add a meaningful title and description for your MR, then submit it.

  1. Merge the Feature Branch (after approval):

Once the MR is approved, merge it into the target branch using GitLab's interface.

  1. Delete the Feature Branch (optional):

Clean up by removing the feature branch after it’s merged.

git branch -d # Delete locally
git push origin --delete # Delete remotely

Top comments (0)