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

Git_Commands_Guide

This document is a comprehensive guide to Git commands, covering configuration, repository setup, file operations, committing changes, branching and merging, undoing changes, stashing, remote repositories, rebasing, tagging, logs, cherry-picking, submodules, cleaning up, and advanced Git features. Each section provides specific commands and their purposes for effective version control. It serves as a quick reference for users to manage their Git repositories efficiently.

Uploaded by

tigip10949
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)
6 views

Git_Commands_Guide

This document is a comprehensive guide to Git commands, covering configuration, repository setup, file operations, committing changes, branching and merging, undoing changes, stashing, remote repositories, rebasing, tagging, logs, cherry-picking, submodules, cleaning up, and advanced Git features. Each section provides specific commands and their purposes for effective version control. It serves as a quick reference for users to manage their Git repositories efficiently.

Uploaded by

tigip10949
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

Comprehensive Git Commands Guide

Configuration Commands
- git config --global user.name "Your Name": Set the global username for commits
- git config --global user.email "your.email@example.com": Set the global email for commits
- git config --list: View all Git configuration settings

Repository Setup
- git init: Initialize a new Git repository
- git clone <repository_url>: Clone an existing repository

Basic File Operations


- git status: Check the status of working directory
- git add <file>: Stage a specific file
- git add .: Stage all modified and new files
- git reset <file>: Unstage a specific file

Committing Changes
- git commit -m "Commit message": Commit staged changes
- git commit --amend -m "New message": Modify the last commit message

Branching & Merging


- git branch: List all branches
- git branch <branch_name>: Create a new branch
- git checkout <branch_name>: Switch to another branch
- git merge <branch_name>: Merge a branch into the current branch

Undoing Changes
- git revert <commit_hash>: Create a new commit that undoes a specific commit
- git reset --hard <commit_hash>: Move HEAD to an older commit and remove all changes

Stashing Changes
- git stash: Save uncommitted changes
- git stash list: Show all stashed changes
- git stash pop: Apply and remove the most recent stash
Remote Repositories
- git remote -v: List all remote repositories
- git push origin <branch>: Push local changes to remote branch
- git pull origin <branch>: Pull latest changes from a remote branch

Rebasing
- git rebase <branch>: Reapply commits on top of another base branch
- git rebase --abort: Cancel the rebase process

Tagging
- git tag: List all tags
- git tag -a <tag_name> -m "Tag message": Create an annotated tag

Logs & History


- git log: View commit history
- git log --oneline: View commit history (one-line format)
- git reflog: Show all movements of HEAD

Cherry-Picking
- git cherry-pick <commit_hash>: Apply a specific commit from another branch

Submodules
- git submodule add <repository_url>: Add a submodule to the repository
- git submodule update --init --recursive: Initialize and update all submodules

Cleaning Up
- git clean -n: Show files that would be deleted
- git clean -f: Delete untracked files

Advanced Git
- git bisect start: Start a binary search to find a bug
- git blame <file>: Show who changed each line in a file

You might also like