A guide to GIT

Eftee Codes
2 min readApr 5, 2023

--

Git is a powerful and essential tool for software developers, but it can be overwhelming for beginners. In this guide, we’ll cover the basics of Git, from installation to creating and managing repositories.

Installation

Before you can start using Git, you’ll need to install it on your computer. You can download Git from the official website for your operating system. Once you’ve installed Git, open a terminal or command prompt and type git --version to verify that it’s installed correctly.

Creating a Repository

A repository is a collection of files and directories that Git tracks changes to. To create a repository, navigate to the directory where you want to create it and run the command git init. This will create a new repository in that directory.

Adding Files

Once you’ve created a repository, you can add files to it using the “git add” command. For example, to add a file called index.html, run the command git add index.html. This tells Git to start tracking changes to the file.

Committing Changes

After you’ve added files to your repository, you can commit changes to them using the git commit command. This creates a snapshot of the changes you’ve made and adds a message describing the changes. For example, to commit changes to the index.html file, run the command git commit -m ‘Updated index.html’.

Branching

Branching is a powerful feature of Git that allows you to create multiple “branches” of your code. This is useful when you’re working on new features or bug fixes and want to keep your changes separate from the main codebase. To create a new branch, run the command git branch <branch-name>. To switch to a different branch, run the command git checkout <branch-name>.

Merging

When you’re finished working on a branch, you can merge it back into the main codebase using the git merge command. This combines the changes from the branch with the main codebase. For example, to merge a branch called “feature-branch” into the main branch, run the command git merge feature-branch.

Pushing and Pulling

Finally, you’ll need to push your changes to a remote repository to share them with others. To do this, run the command git push <remote> <branch>. This uploads your changes to the remote repository. To pull changes from a remote repository, run the command git pull <remote> <branch>. This downloads the changes from the remote repository and merges them into your local repository.

Git is a powerful tool for managing changes to your codebase. By following the basics outlined in this guide, you should be able to create and manage your own repositories, make changes, create and merge branches, and share your changes with others. Keep practicing and exploring the more advanced features of Git to become a Git pro!

Happy Coding!

--

--

Eftee Codes

Full Stack Developer | A tech, psychology and economics geek 😄