💡📖 دستورات ضروری گیت: برگه تقلب شما برای کنترل کارآمد نسخه

Git برای توسعه نرم افزار ضروری است، امکان کنترل نسخه، همکاری موثر بین توسعه دهندگان و مدیریت ایمن تغییرات کد را فراهم می کند. ردیابی تغییرات، بازگشت به نسخه های قبلی و ادغام کار اعضای مختلف تیم را تسهیل می کند و فرآیند توسعه را سازماندهی و کارآمدتر می کند. برای اطلاعات بیشتر و کاوش در دیگر مخازن من یا دسترسی به این پست به زبان پرتغالی، حتماً از نمایه GitHub من در GitHub من دیدن کنید.
🛠️ دستورات
⚙️ پیکربندی و راه اندازی
🔹 پیکربندی git
نام کاربری، ایمیل، ویرایشگر و موارد دیگر را پیکربندی می کند.
Exemplo: `git config --global user.name "Your Name"` sets the user name for all repositories.
🔹 git init
یک مخزن محلی جدید Git را راه اندازی می کند.
Exemplo: `git init` creates a new Git repository in the current directory.
🗃️ صحنه و عکس فوری
🔹 وضعیت git
وضعیت فایل ها (اصلاح شده، پیگیری نشده و غیره) را نشان می دهد.
Exemplo: `git status` to see the current state of files.
🔹 git add
فایل ها را برای commit به مرحله اضافه می کند.
Exemplo: `git add .` adds all modified files to the stage.
🔹 git commit
فایل ها را از استیج کامیت می کند و یک عکس فوری از پروژه را ذخیره می کند.
Exemplo: `git commit -m "message"` commits with a message.
🌳 شعبه و ادغام
🔹 شاخه git
شاخه ها را فهرست می کند، ایجاد می کند یا حذف می کند.
Exemplo: `git branch new-branch` creates a new branch.
🔹 تسویه حساب گیت
به یک شاخه دیگر سوئیچ می کند یا فایل ها را بازیابی می کند.
Exemplo: `git checkout another-branch` switches to the specified branch.
🔹 ادغام git
تاریخچه دو شاخه را ادغام می کند.
Exemplo: `git merge another-branch` merges another-branch into the current branch.
🔍 بازرسی و مقایسه
🔹 git log
تاریخچه ارتکاب را نشان می دهد.
Exemplo: `git log` to see the commit history.
🔹 git diff
تفاوت بین commit ها، شاخه ها و غیره را نشان می دهد.
Exemplo: `git diff` shows unstaged differences.
📤 به اشتراک بگذارید و به روز کنید
🔹 گیت ریموت
مجموعه ای از مخازن ردیابی شده را مدیریت می کند.
Exemplo: `git remote add origin URL` adds a new remote.
🔹 گیت واکشی
اشیاء و ارجاعات را از یک مخزن دیگر دانلود می کند.
Exemplo: `git fetch origin` updates the remote origin information.
🔹 git push
مخزن راه دور را با commit های محلی به روز می کند.
Exemplo: `git push origin main` sends local commits to the main branch in the remote origin.
🔹 کشش عضلانی
مخزن محلی را با آخرین نسخه از راه دور به روز می کند.
Exemplo: `git pull origin main` updates the local with the remote.
🚫 واگرد
🔹 git revert
تغییرات را از یک commit خاص برمی گرداند.
Exemplo: `git revert ` reverts the changes from the specified commit.
🔹 گیت ریست
HEAD را به حالت قبلی بازنشانی می کند.
Exemplo: `git reset --hard HEAD~1` undoes the last commit and changes.
🔹 git rm
فایل ها را از فهرست (مرحله) و فهرست کار حذف می کند.
Exemplo: `git rm file.txt` removes the file from the working directory and the stage.
🔹 git restore
فایل ها را از استیج یا commit history بازیابی می کند.
Exemplo: `git restore file.txt` undoes changes in the file.
🔹 git clean
فایل های ردیابی نشده توسط Git را حذف می کند.
Exemplo: `git clean -fd` removes untracked directories and files.
🌐 کار با ریموت
🔹 git clone
یک مخزن Git موجود را کپی می کند.
Exemplo: `git clone ` clones the repository locally.
🔹 git push (بررسی)
تغییرات را به مخزن راه دور ارسال می کند.
Exemplo: `git push origin main` sends local changes to the main branch in the remote.
🔹 git pull (بررسی)
مخزن محلی شما را با نسخه مخزن راه دور به روز می کند.
Exemplo: `git pull origin main` pulls updates from main in the origin to the local.
🚀 مدیریت پیشرفته
🔹 rebase git
مجدداً در بالای یک پایگاه دیگر commit می کند.
Exemplo: `git rebase main` reapplies the commits from the current branch on top of main.
🔹 سرزنش کردن
نشان می دهد چه کسی هر خط یک فایل را تغییر داده است.
Exemplo: `git blame file.txt` shows the line-by-line authorship.
🔹 git show
اطلاعات مربوط به اشیاء در Git را نشان می دهد.
Exemplo: `git show ` shows information about the commit.
🔹 git log –graph
تاریخچه commit را به صورت نمودار ASCII نمایش می دهد.
Exemplo: `git log --graph` shows the structure of branches and merges.
🔹 git stash
تغییرات محلی را به طور موقت در یک منطقه تمیز ذخیره می کند.
Exemplo: `git stash push -m "message"` saves the current work with a message.
🔹 git stash pop
تغییرات ذخیره شده با git stash را اعمال می کند.
Exemplo: `git stash pop` applies the last stashed change.
🔹 گیلاس چیدن
یک commit را از یک شاخه دیگر به شاخه فعلی اعمال می کند.
Exemplo: `git cherry-pick ` applies the specified commit.
🏷️ برچسب ها
🔹 روز git
برچسب ها را فهرست می کند، ایجاد می کند یا حذف می کند.
Exemplo: `git tag v1.0.0` creates a tag to mark a version.
🧩 قلاب گیت
🔹 قلاب گیت
قلابهای اسکریپت که توسط رویدادهای مهم ایجاد میشوند.
Exemplo: Customize `.git/hooks/pre-commit` to run tests before each commit.
📝 Reflog
🔹 git reflog
گزارشی از تغییرات در مرجع HEAD را نشان می دهد.
Exemplo: `git reflog` helps to find lost commits.
🔗 زیر ماژول ها
🔹 زیر ماژول git
مخزن دیگری را در یک مخزن به عنوان یک زیر ماژول مدیریت می کند.
Exemplo: `git submodule add URL` adds a new submodule.
🛠️ ابزارهای رفع اشکال
🔹 git bisect
از جستجوی دودویی برای یافتن commit که یک اشکال را معرفی کرده است استفاده می کند.
Exemplo: `git bisect start` to start the bisect.
🔧 ابزارهای ادغام
🔹 git mergetool
یک ابزار گرافیکی را برای حل تضادهای ادغام باز می کند.
Exemplo: `git mergetool` after a merge conflict.
🌐 کار با ریموت
🔹 نمایش از راه دور git
اطلاعات مربوط به مخزن راه دور را نشان می دهد.
Exemplo: `git remote show origin` shows details of the remote origin.
🔹 آلو ریموت دار
ارجاعات محلی به شاخه های راه دور حذف شده را حذف می کند.
Exemplo: `git remote prune origin` cleans old references.
🗂️ Git Archive
🔹 آرشیو git
یک آرشیو (مانند .tar یا .zip) از درختان commit ایجاد می کند.
Exemplo: `git archive --format zip --output /tmp/file.zip HEAD` creates a zip file of the current state.
🌳 Git Worktree
🔹 درخت کاری git
چندین درخت کاری مرتبط با یک مخزن را مدیریت می کند.
Exemplo: `git worktree add ../new-directory branch` creates a new worktree.
🛠️ سایر دستورات مفید
🔹 git ls-tree
محتویات یک درخت commit را فهرست می کند.
Exemplo: `git ls-tree HEAD` shows the tree of the HEAD.
🔹 git mv
یک فایل، دایرکتوری یا پیوند نمادین را جابهجا میکند یا نام آن را تغییر میدهد.
Exemplo: `git mv old_file.txt new_file.txt`.
🔹 git gc
فایل های غیر ضروری را پاک می کند و مخزن محلی را بهینه می کند.
Exemplo: `git gc` to optimize the repository.
🔹 git fsck
یکپارچگی فایل سیستم Git را بررسی می کند.
Exemplo: `git fsck` to check for errors.
🔹 git filter-branch
شاخه ها را بازنویسی می کند.
Exemplo: `git filter-branch --tree-filter 'rm -f password.txt' HEAD` removes a file from the entire history.
ℹ️ اطلاعات و راهنما
🔹 کمک بگیرید
راهنمایی برای دستورات Git را نشان می دهد.
Exemplo: `git help commit` shows the help for the commit command.
🔹 نسخه git
نسخه Git نصب شده را نشان می دهد.
Exemplo: `git version` to see the current version.
❌ Git Ignore
🔹 .gitignore
فایلهایی را که عمداً ردیابی نشدهاند را برای نادیده گرفتن مشخص میکند.
Exemplo: Add `*.log` to .gitignore to ignore log files.
📝 ویژگی های Git
🔹 .gitattributes
امکان تعریف صفات برای مسیرهای خاص را فراهم می کند.
Exemplo: Add `*.txt linguist-detectable=true` to .gitattributes.
🗃️ مدیریت LFS (Large File Storage).
🔹 مسیر git lfs
فایل های حجیم را با Git LFS ردیابی می کند.
Exemplo: `git lfs track "*.psd"` to track Photoshop files.
🔹 git lfs ls-files
همه فایلهای ردیابی شده توسط Git LFS را فهرست میکند.
Exemplo: `git lfs ls-files` to see LFS files.
🚀 عملکرد
🔹 اشیاء شمارش git
اطلاعات مربوط به اشیاء در پایگاه داده Git را نشان می دهد.
Exemplo: `git count-objects` to see repository statistics.
🌐 شبکه سازی
🔹 git daemon
به Git اجازه می دهد تا به عنوان دیمون برای پروتکل های بدون حالت خدمت شود.
Exemplo: `git daemon --reuseaddr --base-path=/path/to/repo --export-all --verbose` to serve a repository.
🌳 زیردرخت
🔹 زیردرخت git
ابزاری برای زیرپروژه ها، اجازه می دهد تا مخازن در داخل پروژه های دیگر.
Exemplo: `git subtree add --prefix=subproject subproject_repo master --squash` adds a subproject.