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

Git & GitHub Commands Cheat Sheet

This document is a cheat sheet for Git and GitHub commands, covering configuration, repository setup, file management, committing changes, branching, remote repositories, undoing changes, stashing, comparing changes, and tagging. Each section provides specific commands with brief explanations for their usage. It serves as a quick reference guide for users to efficiently manage their Git repositories.

Uploaded by

harshada.patil3
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)
12 views2 pages

Git & GitHub Commands Cheat Sheet

This document is a cheat sheet for Git and GitHub commands, covering configuration, repository setup, file management, committing changes, branching, remote repositories, undoing changes, stashing, comparing changes, and tagging. Each section provides specific commands with brief explanations for their usage. It serves as a quick reference guide for users to efficiently manage their Git repositories.

Uploaded by

harshada.patil3
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

Git & GitHub Commands Cheat Sheet

1. Configuration
git config --global [Link] "Your Name" → Set username
git config --global [Link] "your@[Link]" → Set email
git config --list → View all configurations

2. Repository Setup
git init → Initialize a new repository
git clone → Clone a remote repository

3. File Management
git status → Check status of files
git add → Stage a file
git add . → Stage all changes
git rm → Remove a file
git mv old_name new_name → Rename/move a file

4. Commit Changes
git commit -m "msg" → Commit staged changes
git commit -am "msg" → Add & commit tracked files
git log → Show commit history
git log --oneline → Compact commit history

5. Branching
git branch → List branches
git branch → Create new branch
git checkout → Switch branch
git checkout -b → Create & switch branch
git merge → Merge branch into current
git branch -d → Delete branch

6. Remote Repositories (GitHub)


git remote -v → Show remote URLs
git remote add origin → Add remote repo
git remote remove origin → Remove remote repo
git push origin → Push branch to remote
git push -u origin → Push & set upstream
git pull → Fetch + merge from remote
git fetch → Fetch changes (no merge)

7. Undoing Changes
git reset --soft → Reset to commit, keep changes staged
git reset --hard → Reset to commit, discard changes
git revert → Create new commit that undoes changes
git checkout -- → Discard changes in file

8. Stash (Temporary Save)


git stash → Save changes temporarily
git stash list → Show stashes
git stash apply → Reapply stash
git stash pop → Apply + remove stash

9. Comparing Changes
git diff → Show unstaged changes
git diff --cached → Show staged changes
git diff commit1 commit2 → Compare two commits

10. Tags
git tag → List tags
git tag → Create a tag
git push origin → Push tag to remote

You might also like