Essential Git Commands for DevOps Engineers

Git is everywhere. Whether you’re deploying microservices, managing Kubernetes manifests, or building CI/CD pipelines — Git is the backbone of modern DevOps workflows. Let’s go through the most important Git commands you should know.


1. Clone a repository

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

Copies a remote repository to your local machine.

2. Check repository status

git status

Shows changed files, staged files, and what’s ready for commit.

3. Add files

git add file.txt
git add .

4. Commit changes

git commit -m "Fix bug in API response"

Saves a snapshot of your changes in the repo history.

5. Push to remote

git push origin main

Sends your commits to the remote repository.

6. Pull updates

git pull origin main

Fetches and merges changes from the remote repository.

7. Create and switch branches

git branch feature-x
git checkout feature-x
# or in one command
git checkout -b feature-x

8. Merge branches

git checkout main
git merge feature-x

Brings changes from one branch into another.

9. Stash changes

git stash
git stash pop

Temporarily saves uncommitted changes so you can switch branches.

10. View commit history

git log --oneline --graph --all

A quick way to visualize your repository history.

Final Thoughts

These are the bread-and-butter Git commands for DevOps engineers. Mastering them makes it easier to manage infrastructure code, CI/CD pipelines, and collaboration with your team. Once you’re comfortable, you can explore more advanced commands like rebase, cherry-pick, and bisect.