Git چیٹ شیٹ
قابلِ تلاش اور قابلِ پرنٹ Git حوالہ — کنفیگ، برانچز، مرجنگ، rebase، ریموٹس، stashing، ٹیگز اور تبدیلیاں واپس کرنا۔ مفت۔
سیٹ اپ اور کنفگ
10git config --global user.name "Jane Doe"
اپنے commits سے منسلک نام سیٹ کریں
git config --global user.email "jane@example.com"
اپنے commits سے منسلک ای میل سیٹ کریں
git config --global init.defaultBranch main
نئے repos کو "main" branch پر شروع کریں
git config --global core.editor "code --wait"
VS Code کو ڈیفالٹ Git ایڈیٹر بنائیں
git config --global pull.rebase true
pull کرتے وقت merge کے بجائے rebase کریں
git config --global alias.co checkout
شارٹ کٹ alias بنائیں (git co)
git config --global --list
تمام global کنفگریشن ویلیوز دکھائیں
git config user.email
موجودہ repo کا ای میل دکھائیں
git config --global color.ui auto
رنگین command-line آؤٹ پٹ فعال کریں
git help <command>
کسی command کا manual صفحہ کھولیں
repos بنائیں اور clone کریں
9git init
موجودہ فولڈر میں نیا repo شروع کریں
git init my-project
نئی directory میں نیا repo بنائیں
git clone https://example.com/repo.git
HTTPS پر remote repo clone کریں
git clone git@example.com:user/repo.git
SSH پر remote repo clone کریں
git clone <url> my-dir
مخصوص directory نام میں clone کریں
git clone --depth 1 <url>
صرف تازہ ترین commit کے ساتھ shallow clone
git clone --branch dev <url>
clone کریں اور مخصوص branch چیک آؤٹ کریں
git clone --recurse-submodules <url>
clone کریں اور تمام submodules شروع کریں
git remote add origin <url>
موجودہ local repo سے remote منسلک کریں
staging اور committing
11git add file.txt
اگلے commit کے لیے ایک فائل stage کریں
git add .
موجودہ directory کی تمام تبدیلیاں stage کریں
git add -A
حذف شدہ سمیت تمام تبدیلیاں stage کریں
git add -p
منتخب hunks کو interactively stage کریں
git commit -m "Add login form"
staged تبدیلیاں پیغام کے ساتھ commit کریں
git commit -am "Fix typo"
tracked فائلیں stage کر کے ایک قدم میں commit کریں
git commit --amend
تازہ ترین commit میں ترمیم کریں
git commit --amend --no-edit
staged تبدیلیاں آخری commit میں شامل کریں
git rm file.txt
فائل ہٹائیں اور حذف کو stage کریں
git mv old.txt new.txt
فائل کا نام بدلیں یا منتقل کر کے stage کریں
git reset file.txt
فائل unstage کریں مگر تبدیلیاں برقرار رکھیں
branches
10git branch
تمام local branches دکھائیں
git branch -a
local اور remote-tracking branches دکھائیں
git switch -c feature/login
نئی branch بنا کر اس پر switch کریں
git switch main
موجودہ branch پر switch کریں
git checkout -b hotfix
branches بنانے اور switch کرنے کا کلاسک طریقہ
git branch -m old-name new-name
branch کا نام بدلیں
git branch -d feature/login
merge شدہ local branch حذف کریں
git branch -D feature/login
غیر merge شدہ local branch زبردستی حذف کریں
git push origin --delete feature/login
remote پر branch حذف کریں
git switch -
پچھلی branch پر واپس switch کریں
merging اور rebasing
10git merge feature/login
ایک branch کو موجودہ میں merge کریں
git merge --no-ff feature/login
merge کریں اور ہمیشہ merge commit بنائیں
git merge --squash feature/login
branch کو ایک staged تبدیلی میں ضم کریں
git merge --abort
conflicts والے merge کو منسوخ کریں
git rebase main
موجودہ branch کے commits main پر دوبارہ چلائیں
git rebase -i HEAD~3
آخری 3 commits میں interactively ترمیم کریں
git rebase --continue
conflicts حل کرنے کے بعد rebase دوبارہ شروع کریں
git rebase --abort
جاری rebase منسوخ کریں
git cherry-pick <hash>
ایک commit موجودہ branch پر لاگو کریں
git mergetool
merge conflicts حل کرنے کا ٹول کھولیں
remotes اور syncing
11git remote -v
کنفگرڈ remotes اور ان کے URLs دکھائیں
git remote add upstream <url>
upstream نامی دوسرا remote شامل کریں
git remote set-url origin <url>
موجودہ remote کا URL تبدیل کریں
git fetch
merge کیے بغیر remote تبدیلیاں ڈاؤن لوڈ کریں
git fetch --all --prune
تمام remotes fetch کریں اور پرانی branches ہٹائیں
git pull
remote تبدیلیاں fetch کر کے ضم کریں
git pull --rebase
pull کریں اور local commits اوپر rebase کریں
git push
local commits remote پر اپ لوڈ کریں
git push -u origin main
push کریں اور upstream tracking branch سیٹ کریں
git push --force-with-lease
دوسروں کو مٹائے بغیر محفوظ force-push
git push origin --tags
تمام local tags remote پر push کریں
inspecting اور comparing
10git status
staged، unstaged اور untracked فائلیں دکھائیں
git status -s
compact مختصر فارمیٹ میں status دکھائیں
git diff
index کے مقابلے unstaged تبدیلیاں دکھائیں
git diff --staged
اگلے commit کے لیے staged تبدیلیاں دکھائیں
git diff main..feature
دو branches کا موازنہ کریں
git diff HEAD~1 HEAD
آخری commit کا اس کے parent سے موازنہ کریں
git show <hash>
ایک commit کی تفصیل اور diff دکھائیں
git show HEAD:file.txt
فائل کسی commit میں جیسی تھی دکھائیں
git log --stat
بدلی فائلوں کے خلاصے سمیت commits دکھائیں
git shortlog -sn
author کے حساب سے commits گنیں
تبدیلیاں واپس کرنا
10git restore file.txt
فائل کی unstaged تبدیلیاں رد کریں
git restore --staged file.txt
فائل unstage کریں مگر تبدیلیاں برقرار رکھیں
git restore --source=HEAD~1 file.txt
فائل کو پہلے کے commit سے بحال کریں
git checkout -- file.txt
local تبدیلیاں رد کرنے کا کلاسک طریقہ
git reset --soft HEAD~1
آخری commit واپس کریں، تبدیلیاں staged رکھیں
git reset --mixed HEAD~1
آخری commit واپس کریں، تبدیلیاں unstaged رکھیں
git reset --hard HEAD~1
آخری commit واپس کر کے تبدیلیاں رد کریں
git revert <hash>
ایک commit کو واپس کرنے والا نیا commit بنائیں
git clean -fd
untracked فائلیں اور directories حذف کریں
git clean -nd
clean کیا ہٹائے گا اس کا preview دیکھیں
stashing
10git stash
غیر committed تبدیلیاں محفوظ کر کے tree صاف کریں
git stash push -m "wip"
تبدیلیاں وضاحتی پیغام کے ساتھ stash کریں
git stash -u
untracked فائلوں سمیت stash کریں
git stash list
تمام stashed تبدیلیوں کے سیٹ دکھائیں
git stash show -p
تازہ ترین stash کا diff دکھائیں
git stash apply
تازہ ترین stash دوبارہ لاگو کر کے رکھیں
git stash pop
تازہ ترین stash دوبارہ لاگو کر کے ہٹائیں
git stash apply stash@{2}
index کے ذریعے مخصوص stash دوبارہ لاگو کریں
git stash drop stash@{0}
ایک stash اندراج حذف کریں
git stash clear
تمام stash اندراجات حذف کریں
tags
9git tag
تمام tags دکھائیں
git tag v1.0.0
HEAD پر lightweight tag بنائیں
git tag -a v1.0.0 -m "Release 1.0.0"
پیغام کے ساتھ annotated tag بنائیں
git tag -a v1.0.0 <hash>
کسی مخصوص پرانے commit کو tag کریں
git show v1.0.0
tag کی تفصیلات دکھائیں
git push origin v1.0.0
ایک tag remote پر push کریں
git push origin --tags
تمام local tags remote پر push کریں
git tag -d v1.0.0
tag مقامی طور پر حذف کریں
git push origin --delete v1.0.0
remote پر tag حذف کریں
logs اور history
12git log
مکمل commit history دکھائیں
git log --oneline
ہر commit ایک لائن والا compact log دکھائیں
git log --oneline --graph --all
branches کو ASCII graph کے طور پر دکھائیں
git log -p
diffs کے ساتھ commit history دکھائیں
git log --author="Jane"
author کے حساب سے history فلٹر کریں
git log --since="2 weeks ago"
تاریخ کی حد سے history فلٹر کریں
git log --pretty=format:"%h %an %s"
log آؤٹ پٹ فارمیٹ کسٹمائز کریں
git blame file.txt
ہر لائن کس نے آخری بار بدلی دکھائیں
git reflog
HEAD کہاں رہا اس کی history دکھائیں
git bisect start
خراب commit کے لیے binary search شروع کریں
git bisect good <hash>
bisect کے دوران commit کو known-good نشان زد کریں
git bisect bad
موجودہ commit کو bad نشان زد کریں
کوئی اندراج “:q” سے میل نہیں کھاتا۔
مدد چاہیے؟
اس ٹول میں کوئی مسئلہ ملا؟ ہماری ٹیم کو بتائیں۔