Git Command
Git Command
▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲
▼▲▼▲▼▲▼
tags : #git
references : git
▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲
▼▲▼▲▼▲▼
🚀 Remote Repositories
Command Description Example Use When Avoid
git Manage git remote -v Viewing -
remote remote remote
repositories connections
git Add a new git remote add origin Connecting to -
remote remote https://github.com/user/repo.git a remote
add repository repository
git Download git fetch origin Updating -
fetch objects and local
refs from repository
Command Description Example Use When Avoid
another with remote
repository changes
git pull Fetch and git pull origin main Synchronizing Avoid
merge with remote have
changes repository uncom
from the chang
remote
repository
git push Upload git push origin main Sharing -
local changes with
commits to others
the remote
repository
🧹 Undoing Changes
Command Description Example Use When Avoid When
git Reset current HEAD git reset - Discarding Avoid if
reset to the specified state -hard recent commits commits are
HEAD~1 pushed
git Create a new commit git revert Reverting a -
revert that undoes changes abc123 specific commit
git Remove untracked git clean - Cleaning up the Be cautious;
clean files from the working f working directory this deletes
directory files
🛠️Advanced Commands
Command Description Example Use When Avoid When
git Apply the changes git cherry- Applying Avoid cherry-
cherry- introduced by some pick specific picking
pick existing commits abc123 commits complex
merges
git bisect Use binary search to git bisect Debugging -
find the commit that start regressions
introduced a bug
git reflog Show the history of git reflog Recovering -
HEAD lost commits
git
archive