Skip to main content

📌 Essential Git Commands

 

📌 Essential Git Commands



🌍 Shape Your Future with AI & Infinite Knowledge...!!

🌐 Want to Generate Text-to-Voice, Images & Videos? 👉 http://www.ai.skyinfinitetech.com 📚 Read In-Depth Tech & Self-Improvement Blogs 👉 http://www.skyinfinitetech.com ▶ Watch Life-Changing Videos on YouTube 👉 https://www.youtube.com/@SkyInfinite-Learning 🔥 Transform Your Skills, Business & Productivity – Join Us Today! 🔥



🔹 Understanding Git Commands

Git commands help developers track changes, collaborate efficiently, and manage project versions. Below are the essential commands every DevOps engineer must know.

1️⃣ Initializing a Git Repository

Command:


git init

Explanation: This command initializes a new Git repository in your project directory. It creates a hidden .git folder that stores all version control data.

Best Practice: Run git init only once per project to avoid nested repositories.



2️⃣ Cloning a Repository

Command:


git clone <repository_url>

Example:


git clone https://github.com/user/repo.git


Explanation: This command copies a remote repository to your local machine, allowing you to work on it.

Best Practice: Always check the branch structure using git branch -a after cloning.



3️⃣ Checking Repository Status

Command:


git status

Explanation: This command displays the current state of the working directory and staging area. It helps you track untracked, modified, or staged files.

Best Practice: Use git status before committing changes to avoid unnecessary files being committed.



4️⃣ Adding Files to Staging Area

Command:


git add <file_name> # OR add all files git add .

Explanation: Moves files from the working directory to the staging area, preparing them for commit.

Best Practice: Use git add -p for selective staging to commit only specific changes.



5️⃣ Committing Changes

Command:


git commit -m "Descriptive commit message"


Explanation: Creates a new version of the project with a descriptive message explaining the changes.

Best Practice: Write meaningful commit messages to improve collaboration. Example:


git commit -m "Fixed login issue by updating authentication logic"


6️⃣ Viewing Commit History

Command:


git log


Explanation: Displays a list of previous commits along with details like author, date, and commit hash.

Best Practice: Use git log --oneline --graph --all for a concise, visual representation of commit history.


7️⃣ Branching and Switching Branches

Commands:


git branch <new_branch_name> git checkout <branch_name>


Explanation: Branching allows developers to work on different features without affecting the main project.

Best Practice: Use git checkout -b <branch_name> to create and switch to a new branch in one step.


8️⃣ Merging Branches

Command:


git merge <branch_name>

Explanation: Combines changes from another branch into the current branch.

Best Practice: Always pull the latest changes using git pull before merging to avoid conflicts.



9️⃣ Pushing Changes to Remote Repository

Command:


git push origin <branch_name>


Explanation: Sends local commits to a remote repository.

Best Practice: Use git push -u origin <branch_name> for the first push to set an upstream branch.



🔟 Pulling Latest Changes from Remote

Command:


git pull origin <branch_name>


Explanation: Fetches and integrates changes from the remote repository into the current branch.

Best Practice: Always run git pull --rebase before starting work to avoid merge conflicts.



🔹 Key Takeaways

✔️ Use git status frequently to check your working state.
✔️ Always write meaningful commit messages.
✔️ Use branches to work on different features safely.
✔️ Pull before push to avoid conflicts.





📚 Top 5 Books That Will Change Your Life!(Top 5 Life-Changing Books) 🚀


1️⃣ Atomic Habits – Build powerful habits and break bad ones!

👉 Get it here: https://amzn.to/4ka28CJ

2️⃣ The Psychology of Money – Master your financial mindset!

👉 Get it here: https://amzn.to/3XiKFOA

3️⃣ Think and Grow Rich – Unlock the secrets to wealth and success!

👉 Buy now: https://amzn.to/4h51HGN

4️⃣ The Power of Your Subconscious Mind – Train your mind for success!

👉 Get it here: https://amzn.to/4idNPuR

5️⃣ Rich Dad Poor Dad – Learn financial lessons the rich teach their kids!

👉 Order here: https://amzn.to/3QzrmNa

Comments

Popular posts from this blog

📊 Monitoring & Logging in Kubernetes – Tools like Prometheus, Grafana, and Fluentd

  Monitoring & Logging in Kubernetes – Tools like Prometheus, Grafana, and Fluentd Monitoring and logging are essential for maintaining a healthy and well-performing Kubernetes cluster. In this guide, we’ll cover why monitoring is important, key monitoring tools like Prometheus and Grafana, and logging tools like Fluentd to help you gain visibility into your cluster’s performance and logs. Shape Your Future with AI & Infinite Knowledge...!! Want to Generate Text-to-Voice, Images & Videos? http://www.ai.skyinfinitetech.com Read In-Depth Tech & Self-Improvement Blogs http://www.skyinfinitetech.com Watch Life-Changing Videos on YouTube https://www.youtube.com/@SkyInfinite-Learning Transform Your Skills, Business & Productivity – Join Us Today! 🚀 Introduction In today’s fast-paced cloud-native environment, Kubernetes has emerged as the de-facto container orchestration platform. But deploying and managing applications in Kubernetes is just half the ba...

How to Use SKY TTS: The Complete, Step-by-Step Guide for 2025

 What is SKY TTS? SKY TTS  is a free, next-generation  AI audio creation platform  that brings together high-quality  Text-to-Speech ,  Speech-to-Text , and a full suite of professional  audio editing tools  in one seamless experience. Our vision is simple — to make advanced audio technology  free, accessible, and effortless  for everyone. From creators and educators to podcasters, developers, and businesses, SKY TTS helps users produce  studio-grade voice content  without expensive software or technical skills. With support for  70+ languages, natural voices, audio enhancement, waveform generation, and batch automation , SKY TTS has become a trusted all-in-one toolkit for modern digital audio workflows. Why Choose SKY TTS? Instant Conversion:  Enjoy rapid text-to-speech generation, even with large documents. Advanced Voice Settings:   Adjust speed, pitch, and style for a personalized listening experience. Multi-...

Introduction to Terraform – The Future of Infrastructure as Code

  Introduction to Terraform – The Future of Infrastructure as Code In today’s fast-paced DevOps world, managing infrastructure manually is outdated . This is where Terraform comes in—a powerful Infrastructure as Code (IaC) tool that allows you to define, provision, and manage cloud infrastructure efficiently . Whether you're working with AWS, Azure, Google Cloud, or on-premises servers , Terraform provides a declarative, automation-first approach to infrastructure deployment. Shape Your Future with AI & Infinite Knowledge...!! Read In-Depth Tech & Self-Improvement Blogs http://www.skyinfinitetech.com Watch Life-Changing Videos on YouTube https://www.youtube.com/@SkyInfinite-Learning Transform Your Skills, Business & Productivity – Join Us Today! In today’s digital-first world, agility and automation are no longer optional—they’re essential. Companies across the globe are rapidly shifting their operations to the cloud to keep up with the pace of innovatio...