Title here
Summary here
git --version # Check Git version
# Change default branch to main
git config --global init.defaultBranch main
git config --global user.name "Your Name" # Set username
git config --get user.name # Retrieve username
git config --global user.email "mail@mail.com" # Set email
git config --get user.email # Retrieve email
git config --global color.ui auto # Enable colored output
git config --global pull.rebase false # Disable rebase on pull
git pull
: This command is used to fetch changes from a remote repository and merge them into your current branch. By default, it performs a merge.
Rebasing: This is an alternative to merging where Git re-applies your local changes on top of the changes fetched from the remote.
git status # Show tracked, untracked, staged files
git add [file name] # Add specific file to staging area
git add . # Add all files to staging area
git commit -m "message" # Commit staged files with a message
git log # Show commit history
q # Exit log view if it's too long
git push # Push changes to the remote repository
git push origin main # Push the main branch to origin in Github
code .
git config --global core.editor "code --wait"
ls ~/.ssh/id_ed25519.pub # Check if SSH key exists
ssh-keygen -t ed25519 # Create a new SSH key
# Press Enter for default location and no passphrase
cat ~/.ssh/id_ed25519.pub # Copy the SSH key
mkdir repos # Create a new directory
cd repos # Navigate to that directory
git clone [paste the ssh link] # Clone the repo from GitHub
cd [the new folder] # Navigate into the cloned folder
git remote -v # Show the linked GitHub repository
git init # Initialize a new Git repository
git add . # Stage all files
git commit -m "message" # Commit the changes
Create an empty repository on GitHub (without README or license)
git remote add origin [ssh key] # Link to the GitHub repository
git branch -M main # Rename current branch to main (if necessary)
git push -u origin main # Push changes to GitHub
Follow the seven rules of a great Git commit message:
Tutorial Video: Conventional Commits
git branch
to see all branches.git branch <branch_name> # Create a new branch
git checkout <branch_name> # Switch to the branch
git checkout -b <branch_name> # Create and switch to a new branch
git checkout main # Switch back to the main branch
Move to the branch you want to merge into
git merge <branch_name>
# Merge changes from <branch_name>
git branch -d <branch_name>
# Delete a merged branch
git branch -D <branch_name>
# Force delete an unmerged branch
git checkout -b <branch_name>
# Create and switch to the new branch
git push origin <branch_name>
# Push the branch to GitHub
git push -u origin <branch_name>
# Link the local branch with the remote one
git log --oneline # View commit history
# Get the commit ID from the log
git reset --hard [9digitId]
# Reset to that commit (deletes progress)
git checkout -b old-state [id]
# Create a new branch at the old commit
git revert [commit_id]
# Revert a specific commit
Git Workflow Models:
Remote Management:
Stashing Changes:
git stash
to temporarily save changes.Rebasing:
Using Tags:
Working with Submodules:
Collaborative Work:
Git Hooks:
Git GUI Clients: