Git Commands Cheat Sheet for Beginners

WHEN SHOULD I USE THESE GIT COMMANDS? GIT COMMANDS CHEAT SHEET FOR BEGINNERS 1. git init • Start a new local Git repository 2. git clone <url> • Copy an existing remote repository to your computer 3. git add <file> or git add . • Stage changes (tell Git which files to include in the next commit) 4. git commit -m "Your message" • Save a snapshot of your staged changes with a message 5. git branch • List, create, or delete branches 6. git checkout -b <branch-name> or git switch -c <branch-name> • Create and switch to a new branch 7. git checkout <branch-name> or git switch <branch-name> • Switch between branches 8. git merge <branch-name> • Combine changes from one branch into your current branch 9. git push origin <branch-name> • Upload your local commits to the remote repository 10. git pull • Fetch latest changes from remote and merge them into your current branch 11. git status • Show what files are changed, staged, or untracked 12. git log • View commit history Quick Workflow Most Teams Use Daily: 1. git pull origin main Get latest code 2. git checkout -b feature/new-login Start your work 3. (code, code, code...) 4. git add . Stage everything 5. git commit -m "Add login page" Save your work 6. git push origin feature/new-login Share it 7. Create Pull Request on GitHub/GitLab 8. After review & approval merge into main Happy coding,! 🚀 #Git #DevOps #90DaysOfDevOps

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories