Essential Git Commands for Beginners.

Essential Git Commands for Beginners.

Overview.

Version Control System (VCS) is a software that helps software developers to work together and maintain a complete history of their work. Git is a version control system that helps programmers and developers manage and track changes to their code at any time. It allows multiple developers to work on a project simultaneously, maintain a history of changes, and revert to previous versions if needed.

In this article, we’ll explore a list of essential Git commands, such as git push, git commit, git pull, and others, that can enhance your workflow and boost productivity.

Screenshot 2024 12 06 201722

Git Installation:

Use the following command to install git.

sudo apt install git
git --version
Screenshot 2024 12 06 175051
Screenshot 2024 12 06 175107

Git Config:

To set the basic configurations on Git like your name and email.

The git config --list command is used to display all the configuration settings Git is currently using.

git config --global user.name "your name"
git config --global user.email "your email"
git config --list
Screenshot 2024 12 06 173935

Git init:

create a local git repository for us in our store folder. This will help to manage the git commands for that particular repository. This is a initialized empty git repository.

Screenshot 2024 12 06 173657

Git status:

The git status command is used to display the current state of your Git repository. It shows information about changes in your working directory and staging area, helping you keep track of what needs to be committed, staged, or ignored.

Screenshot 2024 12 06 175230

This files are untracked files.

Git clone:

The git clone command is used to create a local copy of a remote Git repository. This command downloads the entire repository, including its history, branches, and files, to your local system.

Copy your repository url in your github.

git clone <your repository url>
Screenshot 2024 12 06 175324
Screenshot 2024 12 06 175411

My-register-app is my repo. Go to repo use cd <repo name>/ command and listout my files use ls command.

cd my-register-app/
ls
image 1

Git add:

 Add a specific list of files to the staging area.  

git add .

Add all files of the current directory to the staging area. 

git add --all
Screenshot 2024 12 06 175741

Git log:

The git log command is used to display the commit history of a Git repository. It shows details about each commit, such as the commit hash, author, date, and message. This is essential for understanding the changes made over time in a project.

Screenshot 2024 12 06 181421

Create a new branch:

The git branch command is used to manage branches in a Git repository. Branches are essential for creating separate lines of development, enabling multiple developers to work on different features or fixes simultaneously.

git branch <branch name>

See all the branches present and current branches that we are working on.

git branch
Screenshot 2024 12 06 182230

Git checkout:

Switch to branch Testing from the master branch. 

git checkout <branch name>
Screenshot 2024 12 06 182241

See hidden directories and files within the current directory.

ls -a
Screenshot 2024 12 06 18230011

Create New Repo:

The mkdir command is used to create new directories (folders) in a file system.

mkdir <newreponame>
Screenshot 2024 12 06 183543

Create a File:

The touch command is primarily used to create empty files.

toch <file name>
Screenshot 2024 12 06 183757

Conclusion.

Git is a powerful tool for version control and collaboration. By mastering its basic commands, such as git clone, git commit, and git push, you can efficiently manage your projects and contribute to team workflows. Start practicing today to build your expertise!

Tags: No tags

Add a Comment

Your email address will not be published. Required fields are marked *