Useful Git Commands for Windows

Git Commands for Windows

1. Initial Setup

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git config --global core.editor "code --wait"

2. Repository Basics

git init
git clone https://github.com/username/repo.git
git status
git config --list

3. Staging & Committing

git add filename.txt
git add .
git commit -m "Your commit message"
git commit -am "Quick commit"

4. Branching

git branch feature-branch
git checkout feature-branch
git checkout -b new-branch
git branch

5. Working with Remotes

git remote add origin https://github.com/user/repo.git
git remote -v
git push origin branch-name
git pull origin branch-name

6. Merging and Rebasing

git checkout main
git merge feature-branch

git checkout feature-branch
git rebase main

7. Viewing History

git log
git log --oneline
git diff
git diff --cached

8. Undoing Mistakes

git reset filename.txt
git reset --soft HEAD~1
git reset --hard HEAD~1
git checkout -- filename.txt

9. Stashing

git stash
git stash apply
git stash list

10. Tagging

git tag v1.0
git push origin v1.0

Bonus: Git Help

git help
git help commit

Tips for Windows Users

  • Use Git Bash for a Unix-like experience.
  • Integrate Git with VS Code for visual tools.
  • All commands also work in PowerShell or CMD if Git is in your PATH.

Comments

Popular posts from this blog

Decorators in Pythons | easy way to learn about decorators

Learn about List, Tuples, Sets, Dictionaries in Python