DEV Community

Cover image for Beginner-friendly basics on Git
Marion Mukomi
Marion Mukomi

Posted on

Beginner-friendly basics on Git

Understanding Git
Git tracks every line you change, allowing you room to experiment freely.
Stages of Git
In git, your file travels through 3 main zones

  1. Working directory- The actual files on your disk that you are currently working on.
  2. Staging area- This is a data capture area. You put files here when they are ready to be captured together.
  3. Repository- Once you commit, your changes are safely stored in the project's history.

Version Control System
Use case

  • Collaboration.
  • Storing all the file versions.
  • Restoring previous versions.
  • Figuring out what happened when a specific version is called later.

Benefits

  • Helps manage and protect source code from human error.
  • Keeps track of all modifications made.
  • Comparing earlier versions of the code.
  • Supports developers' workflow.

Configuring Git
Introduce yourself and configure GitHub to your Gitbash by running the following commands;

  1. Check version

Configure name

3.Configure email

4.Check configured items

5.Generate SSH key
Check any existing SSH keys

In case of any existing keys, select the yes option to overwrite.
Generate a new SSH key

Press Enter to get the path that your key is saved on.
Reminder Note the path that the key is saved on for future references.
Start this key as your SSH agent
 Press enter until you get a new line of code, and start that key as your SSH agent.

Add your SSH agent to GitHub

The key generated is your public key. The private key is saved on the path displayed earlier while generating an SSH key in step 5.

Connecting GitHub to your private key
Follow the following process to connect your GitHub to your private key;
Copy the generated key (all the code before the agent Id)
open GitHub> profile > settings > SSH and GPG key > add new ssh key > paste the ssh key copied > finish.

Test the connection
and type yes to confirm.

Pushing (Uploading)
When you have finished a task and committed it locally, you push it to the remote server so your teammates can see it.

Pulling (Downloading)
Before you start working, you should pull the latest changes. This grabs any new code your teammates have uploaded and merges it into your local version.

Collaboration: Push & Pull
Unless you are working alone, your code usually lives on a Remote server like GitHub or GitLab. This allows multiple people to work on the same project.

Basic Commands
 Making a directory command. This creates a new folder(always name the folder after)
 Change a directory command.
 Exits the current folder.
Creates a file inside the folder created above.
 Initialize GitHub.

Track your progress
 Checks which files are modified. Use this often to see "where you are."
 Moves a file into the Staging Area. This adds a new repository inside GitHub.
 Permanently saves the staged changes to the Repository with a note explaining what you did.

Top comments (0)