
ترفندهای Git
میثم ولی اللهی
4 روز پیش
جستجوی پیغام کامیت
$ git log --grep "the commit message"
جستجوی خط
$ git grep "protected ServiceContainer $serviceContainer;"
نمایش برنچهای مرج شده / نشده
$ git branch --merged master
$ git branch --no-merged
حذف تمام برنچ های مرج شده
$ git branch --merged master | xargs -n 1 git branch -d
نمایش کامیت هایی که در برچ جاری هست ولی در مستر وجود ندارد
$ git log master.. --oneline
نمایش فایل های تغییر داده شده بین دو برنچ
# with current branch
$ git diff --name-status master
$ git diff --name-status first-branch..your-branch
$ git diff --stat --color master..your-branch
نمایش فایل هایی که در کامیتها تغییر کرده
$ git whatchanged
$ git whatchanged -p #show with file change log
$ git whatchanged -m -n 1 -p <commit-id>
$ git diff-tree --no-commit-id --name-only -r <commit-ish>
$ git whatchanged --since='2 weeks ago'
نمایش تفاوت فایل با برنچ دیگر
$ git diff master file.extetion
دور انداتن تغییرات لوکال
$ git add . && git checkout -f
نمایش تغییرات کامیت
$ git show <commit-id>
$ git diff-tree -p <commit-id>
نمایش کامیت های یک فایل خاص
$ git log --follow --oneline config/auth.php
$ git log --follow --oneline -p config/auth.php
$ git log --all --full-history -- "**/thefile.*"
بازیابی فایل حذف شده از کامیت
$ git checkout <SHA>^ -- <path-to-file>"
دورانداختن بعضی از تغییرات از فایل / استیج
$ git checkout -p file-name
حذف فایل کامیت شده
$ git rm --cached file-name
ذخیره و بازیابی تغییرات
$ git stash save "name"
$ git stash list
$ git stash pop 1 #1 is number of stash
$ git stash apply 3
$ git stash show -p <stash@{n}>
$ git stash clear
لیست تمام فایل های تا زمان کامیت
$ git ls-tree --name-only -r <commit-ish>
لیست تمام فایل های کانفلیکت خورده
$ git diff --name-only --diff-filter=U
سویچ سریع به برنچ قبلی
$ git checkout -
تغییر آدرس ریموت
$ git remote set-url origin <URL>
استیج کردن قسمتی از تغییرات بجای کل فایل
$ git add -p
لیست فایلهای پیگیری شده/ نشده
$ git ls-files -t
$ git ls-files --others
نمایش تمام فایل های ignore شده
$ git ls-files --others -i --exclude-standard
نمایش تمام برنچ هایی که کامیت مورد نظر را دارند
$ git branch --contains <commit-ish>
نمایش کامیت ها بصورت گروه بندی بر اساس کاربر
$ git shortlog