Git Cheatsheet

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

GIT - CHEATSHEET BY YASHRAJ

Command Description

BEGINNER
git init Initialize a new Git repository.
git config --global user.name "Your Name" Set your name.
git config --global user.email "youremail@example.com" Set your email.
git clone [url] Clone (download) a repository from an existing URL.
git status Check the status of your changes.
git add [file] Add a file to the staging area.
git commit -m "[message]" Commit your changes with a message.
git pull [remote] [branch] Pull (download) and integrate changes from a remote.
git push [remote] [branch] Push (upload) your commits to a remote.
git branch List all branches in the repo.
git checkout -b [branch-name] Create a new branch and switch to it.
git checkout [branch-name] Switch to an existing branch.
git merge [branch] Merge another branch into your active branch.

INTERMEDIATE
git log View commit history.
git diff View changes between commits, commit and working tree, etc.
git show [commit] Show changes made in a specific commit.
git stash Temporarily save changes that you don't want to commit yet.
git stash pop Apply stashed changes back to the working directory.
git clean -n Show what would be removed (dry run).
git clean -f Forcefully remove untracked files.
git remote -v List all remotes for the repository.
git remote add [name] [url] Add a new remote repository.
git fetch [remote] Fetch latest changes from remote without merging.

ADVANCED
git rebase [branch] Reapply commits from one branch onto another.
git commit --amend Modify the last commit.
git rebase -i HEAD~[number] Interactively rebase recent commits.
git merge --no-ff [branch] Merge with a commit even if it's a fast-forward.
git cherry-pick [commit] Apply changes from a specific commit to the current branch.
git tag List all tags.
git tag -a [tagname] -m "[message]" Create an annotated tag.
git push [remote] [tagname] Push a specific tag to remote.
git bisect start Start bisecting to find a commit that introduced a bug.
git bisect good [commit] Mark a commit as good.
git bisect bad [commit] Mark a commit as bad.
git config --list List all Git configurations.
git config --global alias.[alias-name] [git-command] Create a Git alias.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy