DEV Community

Cover image for How to Setup Git and Github
Akinsooto Abidemi
Akinsooto Abidemi

Posted on

How to Setup Git and Github

GitHub is a web-based platform for version control and collaboration that allows developers to host and review code, manage projects, and build software together. Some key features and aspects of GitHub are version control, repositories, branching and merging, pull requests e.t.c.

Setting up on Git involves a few steps. Here's a guide to help you get started:

1. Install Git
Windows: Download and install Git from git-scm.com/downloads

Image description

2. Configure Git
After installing Git, you need to set your username and email:
Open Git Bash

Image description

Then to setup your username and email,
Enter git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"

3. Create a Repository
Initialize a new repository:
To create directory: mkdir Gitlab
To change directory: cd Gitlab

Type

  • mkdir my_project
  • cd my_project
  • git init Image description

To open Vscode (Visual Studio Code)

  • code . This opens visual studio code automatically. Create a new file from Gitlab, name it "index.html"

Image description
Enter as seen below:
<!DOCTYPE html>


Hello world!

Hello world!

This is the first file in my new Git Repo.



Image description

Then Go to terminal - it can be used on Gitbash or Vscode.
From Vscode- Click on the three dot
Then click Run - Click Terminal
Click New Terminal

Image description

4. To add files to the repository:

  • git add .
  • git status

Image description
Image description

5. Commit Changes
Commit your changes with a message:

git commit -m "Adding index.html"

Image description

To create a repository: Go to gitlab.com
Connect the repository on gitbash
To push the origin master - Click +, the drop down
Click on New repository
Image description
Enter name - Gitlab
Check Readme, Click Create Repository
Image description
Image description
Then click on code.
Copy the url
Image description
Then back to Vscode
Type git remote add origin (url)
Example git remote add origin https://github.com/Abidemimodupe/GitLab.git
Connect to a remote repository and push changes:
git remote add origin https://github.com/username/my_project.git
git push -u origin main
Image description

With these steps, you should have a Git repository set up and ready to use.

Top comments (2)

Collapse
 
welshapple profile image
William

Nice informative introduction to Git and Github!

Collapse
 
abidemi profile image
Akinsooto Abidemi

Thank you.