0% found this document useful (0 votes)
2 views

Git-Commands

This document provides a comprehensive list of commonly used Git commands categorized into sections such as Basic Git Setup, Creating/Cloning a Repository, Working with Files, Branching & Merging, Remote Repositories, Viewing History, Undoing Changes, and Clean Up. Each section includes specific commands along with brief descriptions of their functions. It serves as a quick reference guide for users to effectively manage their Git repositories.

Uploaded by

coolmjmi14
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 views

Git-Commands

This document provides a comprehensive list of commonly used Git commands categorized into sections such as Basic Git Setup, Creating/Cloning a Repository, Working with Files, Branching & Merging, Remote Repositories, Viewing History, Undoing Changes, and Clean Up. Each section includes specific commands along with brief descriptions of their functions. It serves as a quick reference guide for users to effectively manage their Git repositories.

Uploaded by

coolmjmi14
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

Commands

Here's a list of commonly used Git commands

🔧 Basic Git Setup


git config --global user.name "Your Name"
git config --global user.email "[email protected]"

📁 Creating / Cloning a Repository


git init # Initialize a new Git repository
git clone <repo-url> # Clone an existing repository

📄 Working with Files


git status # Show the status of changes
git add <file> # Stage a specific file
git add . # Stage all files
git commit -m "message" # Commit staged changes
git pull --rebase origin dev #(fetch and rebase)

🔄 Branching & Merging


git branch # List all branches
git branch <branch-name> # Create a new branch
git checkout <branch-name> # Switch to a branch
git checkout -b <branch-name> # Create and switch to a new branch
git merge <branch-name> # Merge a branch into the current one

Commands 1
🌍 Remote Repositories
git remote -v # View remote connections
git remote add origin <url> # Add a new remote repo
git push -u origin <branch-name> # Push to remote (first time)
git push # Push committed changes
git pull # Pull changes from remote

🕰️ Viewing History
git log # View commit history
git log --oneline # One-line summary
git show <commit-hash> # Show details of a specific commit

🔁 Undoing Changes
git checkout -- <file> # Discard local changes in a file
git reset HEAD <file> # Unstage a file
git revert <commit-hash> # Undo a specific commit safely
git reset --hard <commit-hash> # Reset to an old commit (dangerous!)

🧹 Clean Up
git clean -f # Remove untracked files

Commands 2

You might also like