miniguide

Git Cheatsheet: Essential Commands for DevOps

Introduction

This cheatsheet provides essential Git commands for version control, repository management, and troubleshooting within a DevOps workflow.

Table of Contents

1. Initialize Repository

git init

2. Clone Repository

git clone <repository-url>

3. Check Repository Status

git status

4. Add Changes

git add .

5. Commit Changes

git commit -m "Your commit message"

6. Push Commits

git push origin <branch-name>

7. Pull Updates

git pull origin <branch-name>

8. View Commit Log

git log --oneline

9. Create Branch

git branch <new-branch>

10. Merge Branch

git merge <branch-to-merge>

Bonus: Git Configuration Best Practices

Set Global Username and Email

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Enable Colored Output

git config --global color.ui auto

Set Default Editor

git config --global core.editor "code --wait" # For VS Code

Configure Default Branch Name

git config --global init.defaultBranch main

View All Configurations

git config --list