Git Cheat Sheet

Configuring Git:

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

// Set user email
git config --global user.email "your_email@example.com"

// View current configuration
git config --list
        
    

Creating a Repository:

        
// Initialize a new repository
git init

// Clone a remote repository
git clone 
        
    

Basic Git Workflow:

        
// Check repository status
git status

// Add changes to the staging area
git add 

// Add all changes to the staging area
git add .

// Commit changes
git commit -m "Commit message"

// Push changes to a remote repository
git push origin 

// Pull latest changes from a remote repository
git pull origin 

// Fetch latest changes from a remote repository
git fetch

// Merge changes from a branch
git merge 

// Create a new branch
git branch 

// Switch to a different branch
git checkout 

// Delete a branch
git branch -d 

// View commit history
git log
        
    

Working with Remote Repositories:

        
// Add a remote repository
git remote add  

// View remote repositories
git remote -v

// Rename a remote repository
git remote rename  

// Remove a remote repository
git remote remove 
        
    

Branching and Merging:

        
// Create a new branch and switch to it
git checkout -b 

// Merge a branch into the current branch
git merge 

// Resolve merge conflicts
git mergetool

// Rebase a branch onto another branch
git rebase 

// Abort a rebase
git rebase --abort

// Continue a rebase after resolving conflicts
git rebase --continue
        
    

Undoing Changes:

        
// Discard changes in a file
git checkout -- 

// Undo the last commit, keeping changes in the working directory
git reset HEAD~

// Discard all changes in the working directory
git reset --hard HEAD
        
    

Tagging:

        
// Create a new tag
git tag 

// Create an annotated tag with a message
git tag -a  -m "Tag message"

// Push tags to a remote repository
git push origin --tags

// List tags
git tag