0% found this document useful (0 votes)
80 views1 page

Git Cheatsheet

The document provides an overview of common Git commands for setup and configuration, basics like adding and committing changes, branching and merging, undoing changes, advanced commands, troubleshooting, and working with remote repositories. Key commands are listed to initialize a repository, track changes, commit changes, switch and manage branches, push and pull from remote repositories, and undo changes. The cheat sheet acts as a quick reference guide for the most frequently used Git commands.

Uploaded by

Yunusa Sanusi
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)
80 views1 page

Git Cheatsheet

The document provides an overview of common Git commands for setup and configuration, basics like adding and committing changes, branching and merging, undoing changes, advanced commands, troubleshooting, and working with remote repositories. Key commands are listed to initialize a repository, track changes, commit changes, switch and manage branches, push and pull from remote repositories, and undo changes. The cheat sheet acts as a quick reference guide for the most frequently used Git commands.

Uploaded by

Yunusa Sanusi
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/ 1

GIT CHEAT SHEET

NEVER FORGET YOUR GIT COMMANDS!

www.linkedin.com/in/varunkumar5/

SETUP AND CONFIGURATION UNDOING CHANGES


Initializes a new Git repository and begins Remove changes from the staging area, but retain
git init <directory> git reset
tracking an existing directory. them in the working directory.

git config --global Define author name to be used for all commits by git revert <commit- Create a new commit that undoes the changes from
user.name <name> the current user id> a specified commit.

git config --global Define the author email to be used for all git commit --amend Modify and add changes to the most recent commit.
user.email <email> commits by the current user.

Display all configuration settings for git on the git reset --hard Reset your branch to a previous commit,
git config --list
machine. <commit-id> discarding changes after the specified commit.

BASICS ADVANCED COMMANDS


git clone Clone (or copy) a repository from an existing Temporarily save changes that you don't want to
<repository-url> URL. git stash
commit immediately.

Add changes in the specified file or directory to Apply previously stashed changes to the working
git add <file-name> git stash apply
the staging area. directory.
git commit -m Commit changes in the staging area with a
git clean -f Remove untracked files from the working
<message> descriptive message. directory.

Show modified files in the working directory, git rebase -i Reapply commits on top of another base tip, often
git status
staged for your next commit. used to modify commit history.
<commit-id>

git log Display the entire commit history using the


default format.
TROUBLESHOOTING
BRANCHES AND MERGING git bisect start
git bisect bad Use binary search to find which commit introduced
git branch <branch- an error.
Create a new branch off the current branch. git bisect good <cid>
name>

git checkout <branch- git merge --abort


Switch to the specified branch. Abort the current operation and get back to the
name> git rebase --abort state before the operation began.
git bisect reset
git checkout -b
Create a new branch and switch to it.
<branch-name> git diff --name-only Display all files that have conflicts between
--diff-filter=U merging branches.
git merge <branch- Merge the specified branch into the current
name> branch. git checkout -b Create a new branch pointing to the commit where
<branch> <commit-id> the branch was deleted.
git branch -d
Delete the specified branch.
<branch-name> View a log of where your HEAD and branch
git reflog
references have pointed in the past.

REMOTE REPOSITORIES git shortlog


Summarize git log output and group commits by
authors.
git remote add
Add a remote repository for tracking.
<remote> <repo-url>
git log --graph -- Display a graphical representation of the commit
oneline history.
List all remote repositories associated with the
git remote -v
current repo.
git log -- Search for commits with a log message that
grep="search_term" matches the specified term.
git push <remote-
Push your branch to the specified remote.
name> <branch-name>
gitk Open a graphical interface to navigate and
visualize the commit tree.
git pull <remote- Pull latest changes from the specified remote and
name> <branch-name> merge into your branch.
git checkout <commit- Temporarily switch to a previous version of a
id> -- <file-name> specific file.
git remote rm Remove the connection to the specified remote
<remote-name> repository.

You might also like