⚡ Git Workflow: Add, Commit, Push, Pull

Pankaj Kholiya
2 min readSep 18, 2023

--

Git is like a time machine for your code. It helps you keep track of changes, work with others, and stay organized. The basic Git workflow involves four simple steps: Add, Commit, Push, and Pull. Let’s dive into each of them.

Git Work FLow

💼 Add 💼

Add: Get Ready to Save Changes

# 📂 To stage one file
git add filename

# 📦 Stage all changes in the current directory and its subdirectories
git add .

Before Git can remember your changes, you need to tell it what to pay attention to. This is the “Add” step. You use this step to stage your files for commit. Staging lets you review your changes and organize them neatly.

📋 Commit 📝

Commit: Get Ready to Save Changes

# 💾 Commit with a message
git commit -m "Add new feature X"

Once your changes are staged, it’s time to save them permanently. This is called a “Commit.” A commit is like taking a snapshot of your code at a particular moment, with a short message to explain what you did. Your message should be brief but clear so that you and your team can understand what this commit is all about.

🚀 Push 🚀

Push: Share Your Commits

# 🚀 Push your commits to the remote repository
git push origin master

Commits live on your computer until you share them. To do that, you “Push” them to a remote server, like GitHub or GitLab. This step uploads your commits so that others can see them and work with you. This is vital for teamwork and keeping your code safe.

🌀 Pull 🌀

Pull: Get the Latest Changes

# 🔄 Get the latest changes from the remote repository
git pull origin master

When you work with a team, everyone is making changes. To get the newest stuff, you “Pull” from the remote repository. Pulling helps you stay up to date and avoid conflicts with your teammates.

📋 Clone 📋

Clone: Cloning a Repository

# 📦 Clone a repository from a remote URL
git clone https://github.com/username/repo-name.git

Cloning is like getting a copy of someone else’s project. It’s your starting point for working together. To clone a repository, you use this step to create a new directory with all the code and history from the remote repository. Now you can make changes, commit them, and send them back to the remote repository.

In a nutshell, understanding this simple Git workflow (Add, Commit, Push, Pull) will help you manage your code and collaborate smoothly with others in the exciting world of software development.

--

--

Pankaj Kholiya

Lover of all things tech, with a knack for creating beautiful, functional applications. Fullstack computer science engineer by day, code tinkerer by night.