الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

الفصل 4الاسم في الدورة: Working with remotes

Share work with remote repositories

A remote is another copy of the repository — usually on GitHub. You push your commits to it and fetch or pull the commits of others. This chapter covers clone, remotes, fetch, pull, push and tracking branches.

  • 5 الدروس
  • 2 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

4.1

Clone a repository

git clone copies a whole repository with its history and sets the remote origin.

git clone git@github.com:s0sta/infra-shop.git
git clone --depth 1 https://github.com/s0sta/it-notes.git
cd infra-shop && git remote -v
origin  git@github.com:s0sta/infra-shop.git (fetch)
origin  git@github.com:s0sta/infra-shop.git (push)

تذكّر

Use SSH URLs (git@github.com:…) with a key, or HTTPS with a token. Passwords do not work on GitHub any more.

الأوامر في هذا الدرس

4.2

Manage remotes

A repository can have several remotes — for example origin (your fork) and upstream (the original project).

git remote add upstream https://github.com/hashicorp/terraform-provider-azurerm.git
git remote -v
git remote set-url origin git@github.com:s0sta/infra-shop.git
git remote rename upstream source
git remote remove source

الأوامر في هذا الدرس

4.3

Fetch and pull

fetch downloads new commits but changes nothing in your branch. pull = fetch + merge (or rebase) into your branch.

git fetch origin
git log --oneline main..origin/main
git pull
git pull --rebase
git fetch --prune
CommandChanges your branch?
git fetchNo, only origin/…
git pullYes, merges origin/BRANCH
git pull --rebaseYes, puts your commits on top of the new ones

في العمل

git fetch + look + then merge is safer than a blind git pull on important branches.

الأوامر في هذا الدرس

4.4

Push your branch

git push sends your commits. The first push of a new branch sets the upstream with -u.

git push -u origin feature/web-network
git push
git push origin --delete feature/old
git push --tags
git push --force-with-lease

انتبه

--force overwrites the remote branch and can delete others' commits. If you must rewrite a pushed branch (your own feature branch), use --force-with-lease — it refuses when someone else pushed meanwhile.

الأوامر في هذا الدرس

4.5

Understand tracking branches

A local branch can track a remote branch. Then git status tells you if you are ahead or behind.

git branch -vv
* feature/web-network 3f2a9c1 [origin/feature/web-network: ahead 2] Add NSG rules
git status
Your branch is ahead of 'origin/feature/web-network' by 2 commits.
git branch -u origin/main main

الأوامر في هذا الدرس

كل الأوامر في هذا الفصل