0% found this document useful (0 votes)
2 views2 pages

Git Commands

This document provides a categorized list of important Git commands for setup, repository management, branching, pushing/pulling, merging, stashing, logging, undoing changes, remote management, and tagging releases. Each category includes specific commands with brief descriptions. Additionally, it offers assistance for creating a printable cheat sheet or hands-on practice with GitHub.

Uploaded by

suchitkapale117
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Git Commands

This document provides a categorized list of important Git commands for setup, repository management, branching, pushing/pulling, merging, stashing, logging, undoing changes, remote management, and tagging releases. Each category includes specific commands with brief descriptions. Additionally, it offers assistance for creating a printable cheat sheet or hands-on practice with GitHub.

Uploaded by

suchitkapale117
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Sure Suchit!

Here's a list of important and commonly used Git commands — categorized


for easier understanding:

1. Git Setup & Configuration

git config --global user.name "Your Name"


git config --global user.email "[email protected]"

2. Repository Basics

git init # Initialize a new Git repo


git clone <repo-url> # Clone remote repo to local
git status # Check current status
git add <file> # Stage a specific file
git add . # Stage all changes
git commit -m "Your message" # Commit with message

3. Branching

git branch # List all branches


git branch <branch-name> # Create new branch
git checkout <branch-name> # Switch to branch
git checkout -b <branch-name> # Create & switch to branch

4. Pushing & Pulling

git push # Push changes to remote


git push -u origin <branch> # Push and set upstream branch
git pull # Pull latest changes from remote
git fetch # Fetch latest branches and commits

5. Merging & Rebase

git merge <branch> # Merge branch into current branch


git rebase <branch> # Rebase current branch onto given branch

6. Stashing Changes

git stash # Save uncommitted changes


git stash apply # Apply latest stashed changes
git stash list # List all stashes
git stash drop # Delete the latest stash
7. Log & History

git log # Show commit history


git log --oneline # Compact log view
git diff # Show changes not staged
git diff --staged # Show staged changes

8. Undo & Reset

git reset --soft HEAD~1 # Undo last commit, keep changes staged
git reset --mixed HEAD~1 # Undo last commit, keep changes unstaged
git reset --hard HEAD~1 # Completely remove last commit
git checkout -- <file> # Discard changes in a file

9. Remote Management

git remote -v # View current remotes


git remote add origin <url> # Add remote origin
git remote remove origin # Remove a remote

10. Tagging Releases

git tag v1.0 # Create a tag


git tag -a v1.0 -m "message" # Create an annotated tag
git push origin v1.0 # Push tag to remote

If you want a printable cheat sheet PDF or want to practice Git hands-on using GitHub,
I can help with that too. Just say the word!

You might also like