Wednesday, April 13, 2022

Git #2: Setting Up Git Using VS Code + GitLab

Install and Set-Up

  • Download Git Bash and install. > download here
  • Git Bash looks like cmd. Open it on your windows.
  • Try typing "git" and hit enter. To know if git has been properly installed, other commands will appear.

Generating SSH Key

  • Type the code below in Git Bash command window.
ssh-keygen -t rsa -b 4096 -C “your email
  • Change the red text with your email.
  • Then, just click 'Enter' until you get the key's randomart image.
  • To check, go to C: (pc) > Users > DELL (pc name) > .ssh > open id_rsa (mic publisher) using VS Code.
  • You'll see a long code starting with ssh-rsa and ending with your email. Copy everything and go to GitLab.
  • Go to profile icon (on top right) and click Edit Profile.
  • From the left menu bar, click SSH Keys.
  • Paste the code you copied earlier into the Key column. Change the title to 'pc key' or anything you prefer. Click Add Key button.
  • Now go to any of your existing projects on GitLab and click Clone with SSH.

  • Open Git Bash, type " cd htdocs " (make sure you're in xampp) and click enter.
  • Then type, " git clone " + paste the SSH that you copied, and click enter. If there appear a message, type in "yes".
  • In the Git Bash, type " git config --global user.name Nur Farizah(your username in gitlab) ". Hit enter,
  • Then, " git config --global user.email yourEmail ". Hit enter.

Connecting with VS Code

  • Open the project folder in VS Code. VSC > Open Folder > C: > xampp > htdocs > your project folder > Open Folder.
  • To know if you're already in the folder, you'll see the name of your project folder at the top of the VSC window.

To Push

  • VSC > File > New File. Create a simple HTML. Save the file name.php.
  • Click the '+' button to stage changes.

  • We'll commit/push the one added into the Staged Changes section.
  • Add any message about your changes in the box above it, and click the Commit button.

  • Go to the bottom left, where you can see a turning arrow button. Click on it. If a message appears, click OK. (This button will do pull, then push. It'll check if there's any conflict).

Creating A Branch

  • Click the button (branch button) next to the turning arrow button earlier.
  • Choose Create a new branch...
  • Enter any name you want. (Can use format like, F(initial)-Add-Changes).
  • Click Publish Branch, and proceed to clicking the same arrow button.

Create New Merge Request in GitLab

  • Open GitLab > Choose your project > click Merge Request menu.
  • Click Create Merge Request.

  • Enter the title, and you can choose to set the Assignee to yourself or any person in charge.
  • Click Create Merge Request button.

Done!

No comments:

Post a Comment

Komen atau sebarang pertanyaan di sini :)

WordPress #3 | How to Change Website URL

Hi. Today we're gonna look at how to change your website URL in case you messed up. In this case, yes, I messed up. That is why this pos...