נבנה על ידיBuilt by Ariel Yohimovich

חזרה למפגשBack
PythonPython

Git ו-GitHubGit & GitHub

מפגש 20: commit, branch, merge, push ו-README טוב.Session 20: commit, branch, merge, push and a good README.

מה נעשה היוםToday's plan

  • למהWhy
  • commitCommit
  • היסטוריהHistory
  • .gitignore.gitignore
  • ענפיםBranches
  • GitHubGitHub
נושאTopic 1

למהWhy

למה Git?Why Git?

  • final_v2_REAL.py זה לא שיטהfinal_v2_REAL.py is not a system
  • היסטוריה מלאה, חזרה לכל נקודהFull history, return to any point
  • Git ≠ GitHubGit ≠ GitHub

אנלוגיהAnalogy

Git הוא כמו כפתור "שמור משחק" במשחק מחשב: לפני הבוס שומרים, ואם נכשלים, חוזרים בדיוק לשם בלי להתחיל הכול מחדש.Git is like a game's "save" button: save before the boss, and if you lose, go back exactly there without starting over.
נושאTopic 2

commitCommit

המאגר וה-commit הראשוןThe repo and the first commit

אנלוגיהAnalogy

staging הוא כמו עגלה בסופר: add שם מוצרים בעגלה, ו-commit הוא הקופה. אפשר למלא את העגלה בהדרגה ולשלם פעם אחת.Staging is like a supermarket cart: add puts items in the cart, and commit is the checkout. Fill the cart gradually, pay once.
נושאTopic 3

היסטוריהHistory

היסטוריה ושינוייםHistory and changes

  • git diff: מה השתנה ועדיין לא נשמרgit diff: what changed and isn't saved yet
  • git log --oneline: רשימת ה-commitsgit log --oneline: the list of commits
  • הודעה טובה: מה ולמה, בזמן הווהA good message: what and why, in the present tense

אנלוגיהAnalogy

git log הוא כמו יומן מסע: כל רשומה אומרת איפה הייתם ומה עשיתם. הודעה כמו "עשיתי דברים" לא תעזור לאף אחד בעוד חודש.git log is like a travel journal: each entry says where you were and what you did. An entry like "did stuff" helps nobody a month later.
נושאTopic 4

.gitignore.gitignore

.gitignore.gitignore

  • לא שומרים .venv/ ו-__pycache__/Don't save .venv/ and __pycache__/
  • לעולם לא סיסמאות ומפתחותNever passwords and keys
  • שורה = תבניתOne line = one pattern

אנלוגיהAnalogy

.gitignore הוא כמו רשימת "לא לארוז" לטיסה: אין טעם לסחוב את מה שאפשר לקנות שם, ואת מה שמסוכן אסור להעלות למטוס בכלל..gitignore is like a "don't pack" list for a flight: no point lugging what you can buy there, and dangerous things never go on board.
נושאTopic 5

ענפיםBranches

ענפים ומיזוגBranches and merging

  • git switch -c feature יוצר ענף ועובר אליוgit switch -c feature creates a branch and moves to it
  • commits בענף לא נוגעים ב-mainCommits on a branch don't touch main
  • git merge feature מאחדgit merge feature combines

אנלוגיהAnalogy

ענף הוא כמו טיוטה של מכתב: כותבים, מוחקים ומנסים בחופשיות, ורק כשמרוצים מעתיקים לגרסה שנשלחת.A branch is like drafting a letter: write, erase and experiment freely, and only when happy copy it into the version that gets sent.
נושאTopic 6

GitHubGitHub

להעלות ל-GitHubPushing to GitHub

  • יוצרים repo ריק באתרCreate an empty repo on the site
  • git remote add origin <url>git remote add origin <url>
  • git push מעלה, git pull מורידgit push uploads, git pull downloads

אנלוגיהAnalogy

GitHub הוא כמו כספת בענן לדפדפת השמורה שלכם: אם המחשב נגנב, הכול עדיין שם, וגם חברים יכולים לקבל עותק.GitHub is like a cloud safe for your saved binder: if the laptop is stolen, it's all still there, and friends can get a copy too.

final_v2_REAL.py זה לא שיטהfinal_v2_REAL.py is not a system

היסטוריה מלאה, חזרה לכל נקודהFull history, return to any point

Git ≠ GitHubGit ≠ GitHub

git init יוצר מאגרgit init creates a repo

git add → אזור ההכנה (staging)git add → staging area

git commit -m "..." שומרgit commit -m "..." saves

git diff: מה השתנה ועדיין לא נשמרgit diff: what changed and isn't saved yet

git log --oneline: רשימת ה-commitsgit log --oneline: the list of commits

הודעה טובה: מה ולמה, בזמן הווהA good message: what and why, in the present tense

לא שומרים .venv/ ו-__pycache__/Don't save .venv/ and __pycache__/

לעולם לא סיסמאות ומפתחותNever passwords and keys

שורה = תבניתOne line = one pattern

git switch -c feature יוצר ענף ועובר אליוgit switch -c feature creates a branch and moves to it

commits בענף לא נוגעים ב-mainCommits on a branch don't touch main

git merge feature מאחדgit merge feature combines

יוצרים repo ריק באתרCreate an empty repo on the site

git remote add origin <url>git remote add origin <url>

git push מעלה, git pull מורידgit push uploads, git pull downloads

מה למדנוWhat we learned

  • final_v2_REAL.py זה לא שיטהfinal_v2_REAL.py is not a system
  • git init יוצר מאגרgit init creates a repo
  • git diff: מה השתנה ועדיין לא נשמרgit diff: what changed and isn't saved yet
  • לא שומרים .venv/ ו-__pycache__/Don't save .venv/ and __pycache__/
  • git switch -c feature יוצר ענף ועובר אליוgit switch -c feature creates a branch and moves to it
  • יוצרים repo ריק באתרCreate an empty repo on the site

עכשיו לתרגולNow, practice

5 תרגילים ו-2 אתגרים, עם בדיקה אוטומטית5 exercises and 2 challenges, auto-checked
הערות מרצהSpeaker notes

נבנה על ידיBuilt by Ariel Yohimovich