Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

Git & Github

Learning the concepts before the commands


‫ﺷﻨﻮ ﻛﻨﺪﻳﺮو ﻛﻞ ﻳﻮم ؟‬

We create and edit document (texts,images,etc..)


‫روﺗﲔ دﻳﺎﻟﻨﺎ‬

1. Create a file
2. Save it
3. Edit it
4. Save it again
5. Go to 1
F il
ec
re
a tio
n

Ad
d
so
m
ec
od
e
De
le
te
so
m
ec
od
e
‫روﺗﲔ دﻳﺎﻟﻨﺎ‬

Ad
d
an
ot
h er
co
de
‫اﻟﺰﻣﻦ‬
‫َﻀﻤﻮ اﻟﻜﻮد دﻳﺎﻟﻨﺎ‬
‫ﻓﺎش ﻛﻨﺒﻐﻴﻮ ﻧ ْ‬
‫ﻋﺒﺪهللا‬
F il
ec
re
a tio
n

‫ﻣﺤﻤﺪ‬
Ad
d
so
m
ec
od
e

‫ﺟﻴﻼﱄ‬
De
le
te
so
m
ec
od
e
‫ﻣﺤﻤﺪ‬

Ad
d
‫ﻛﺎﻳﻦ ﻣﺸﻜﻞ‬

an
ot
h er
co
de
‫اﻟﺰﻣﻦ‬
‫ﻛﺎﻳﻦ ﻣﺸﻜﻞ‬
‫اﻟﺰﻣﻦ‬

‫● ﻓﻮﻗﺎش ﻧﺪارت ال ‪ modification‬؟‬


‫● ﺷﻨﻮ ﺗﻐﲑ ؟‬
‫● ﻋﻼش ﺗﻐﲑ ؟‬
‫● ﺷﻜﻮن دار ال ‪ modification‬؟‬
‫ﺷﻨﻮ اﻟﺤﻞ ؟‬
‫ﻫﻮ ﻧﻈﺎم ﻟﺘﺘﺒﻊ اﻟﺘﻐﲑات ﻓﻲ اﻟﻜﻮد ﻣﺼﻤﻢ ﻟﻠﺘﻌﺎﻣﻞ اﻟﻤﺸﺎرﻳﻊ ﻣﻊ اﻟﺼﻐﲑة ) اﻟﲇ ﻓﻴﻬﺎ ﻣﱪﻣﺞ واﺣﺪ( و‬
‫ﺣﱴ اﻟﻜﺒﲑة ﺟﺪًا ﺑﴪﻋﺔ وﻛﻔﺎءة‬
Download & install git at
http://git-scm.com

https://www.youtube.com/watch?v=nbFwejIsHlY
Basic concepts
‫ﻣﻔﺎﻫﻴﻢ أﺳﺎﺳﻴﺔ‬
Repository

Directory 1

Directory 2

file.txt

file.py

image.jpg
Repository

$ mkdir new_project

$ cd new_project

$ git init

.Git ‫ﺗﺎﺗﺮﺟﻌﻠﻴﻨﺎ ﺑﺮوﺟﻲ دﻳﺎﻟﻨﺎ ﻛﱪوﺟﻲ‬ : git init


‫‪Status‬‬

‫‪$ git status‬‬

‫‪ :git status‬ﺗﺎﺗﺮﺟﻌﻠﻴﻨﺎ اﻟﻮﺿﻊ اﻟﺤﺎﱄ دﻳﺎل ﺑﺮوﺟﻲ ‪ .Git‬ﻫﻞ ﻫﻨﺎك ﻣﻠﻔﺎت ﺟﺪﻳﺪة‬
‫او ﻛﻮد ﺟﺪﻳﺪ او ﺗﻐﻴﲑات ﻓﻲ ﻛﻮد ﻗﺪﻳﻢ‪.‬‬
Commit
File creation

‫ﻋﺒﺪهللا‬
Delete some code

‫ﻣﺤﻤﺪ‬
‫ﺟﻴﻼﱄ‬ Add some code
Commit

Add another code


‫ﻣﺤﻤﺪ‬
‫اﻟﺰﻣﻦ‬
Git Add

$ git add <file_1_wich_has_been_modified>

$ git add <new_file>

‫ ﺗﺎﺗﺴﺘﻌﻤﻠﻬﺎ ﻣﻦ ﺗﺒﻐﻲ ﺗﺰﻳﺪ‬:git add


.Commit ‫ﻴﴚ ﺟﺪﻳﺪ وﻻ ﺷﻜﻮن ﻓﻴﴚ ﻟﻴﺒﺎﻏﻲ دﺧﻞ ﻓﻞ‬ ِ ‫ِﻓ‬
Commit

$ git add <file_1_wich_has_been_modified>

$ git add <new_file>

$ git commit --message “A meaningful message about this change”

https://dev.to/jacobherrington/how-to-write-useful-commit-messages-my-commit-message-template-20n9
Branch ‫اﻟﻔﺮع‬

Master branch

HEAD of master

.Commit ‫ إﺷﺎرة إﱃ أﺣﺪث‬:Head


.‫ ﻫﻮ اﻟﻔﺮع اﻷوﱄ و اﻟﺮﺋﻴﴘ‬:Master
Branch ‫اﻟﻔرع‬
Master

my-feature

$ git branch my-feature

( One Feature = One Branch )


‫ وﻟﻜﻦ راك ﺑﺎﻗﻲ ﻓﺎﻟﻔﺮع ﻟﻴﻜﻨﱵ ﻓﻴﻪ )ﻓﻬﺎد‬.‫ ﺗﺎﺗﺨﻠﻖ ﻓﺮع ﺟﺪﻳﺪ ﺻﻮرة ﻣﻦ اﻟﻔﺮع اﻟﺤﺎﱄ‬:Git branch
.(Master ‫اﻟﻤﺜﺎل‬
Branch
Master

my-feature

$ git checkout my-feature

$ git branch

.(my-feature ‫ )ﻓﻬﺎد اﻟﻤﺜﺎل‬.‫ اﻧﺘﻘﺎل اﱃ ﻓﺮع ﺟﺪﻳﺪ‬:Git checkout


‫ ﻛﱰﺟﻌﻠﻴﻨﺎ ﺟﻤﻴﻊ اﻟﻔﺮوع دﻳﺎل اﻟﻤﴩوغ دﻳﺎﻟﻨﺎ‬:Git branch
Log
$ git log

‫ ﻛﺎﻳﻦ ﻓﻴﻬﻢ‬Head ‫ اﻟﲇ‬commits ‫ ﻧﺘﺎع ﺟﻤﻴﻊ ال‬logs ‫ ﻛﱰﺟﻊ ﻟﻴﻨﺎ‬:Git log

$ git log my-feature

‫ اﻟﲇ ﻛﺎﻳﻨﲔ ﻓﻲ اﻟﻔﺮع ﻓﻲ ﻫﺬا‬commits ‫ ﻧﺘﺎع ﺟﻤﻴﻊ ال‬logs ‫ ﻛﱰﺟﻊ ﻟﻴﻨﺎ‬:Git log my-feature
( my-feature ) ‫اﻟﻤﺜﺎل‬
Diff
$ git diff

$ git diff <a_specific_file_or_folder>

Master

my-feature

$ git diff master my-feature

options ‫ ﻛﱰﺟﻊ ﻟﻴﻨﺎ اﻟﺘﻐﲑات اﻟﲇ وﻗﻌﻮ ﻋﲆ ﺣﺴﺎب ﺷﻨﻮ ﻧﻌﻄﻴﻮﻫﺎ ﻓﻲ ال‬:Git diff
( … ‫ِﴚ‬
ِ ‫ أو ﻣﺎ ﺑﲔ اﻟﻔﻴ‬commits ‫)ﺗﻘﺪر ﺗﻜﻮن ﻣﺎ ﺑﲔ اﻟﻔﺮوع أو ﻣﺎ ﺑﲔ ال‬
Merge ( ‫) اﻟﺪﻣﺞ‬
Master

my-feature

$ git checkout master

$ git merge my-feature

‫ ﻓﻲ ﻫﺬا اﻟﻤﺜﻞ ( ﻣﻊ اﻟﻔﺮع اﻟﺤﺎﱄ‬my-feature ) ‫ ﺗﺪﻣﺞ اﻟﻔﺮع اﻟﻤﺤﺪد‬:Git merge


Merge
Master

my-feature

$ git checkout master master ‫اﻧﺘﻘﺎل اﱃ ﻓﺮع‬ ●

$ git diff master..my-feature master ‫ ﻣﻘﺎرﻧﺔ ب‬my-feature ‫ﻋﺮض اﻟﺘﻐﲑات اﻟﲇ وﻗﻌﺖ ﻓﻲ‬ ●

$ git merge my-feature


( master ‫ ﻣﻊ اﻟﻔﺮع اﻟﺤﺎﱄ ) ﻓﻲ ﻫﺬا اﻟﻤﺜﻞ‬my-feature ‫دﻣﺞ‬ ●
Delete a branch
Master

my-feature

$ git branch --delete my-feature


Local Remote
Repository Repository

Your computer Remote server


Let’s create a remote repo !

Go to Github, create a repo: http://github.com/new

$ git remote add origin https://github.com/<user>/<project>.git

local ‫ اﻟﻤﴩوع دﻳﺎﻟﻨﺎ وﻟﻜﻦ اﻟﻜﻮد ﻣﺰاﻟﻮ ﻓﻲ‬serveur remote ‫ ﻏﺎدي ﺗﻌﺮف‬:Git remote add
Push
‫ﺷﺎرك اﻟﻜﻮد دﻳﺎﻟﻚ ﻣﻊ اﻟﻨﺎس‬

$ git push <remote> <branch>

Pull
‫ﺟﻴﺐ اﻟﻜﻮد ﻧﺘﺎع اﻟﻨﺎس‬

$ git pull <remote> <branch>


Clone
$ git clone https://github.com/<user>/<project>.git

Remote Repo ‫ ﺗﺴﺘﻨﺴﺦ‬:Git clone


Local ‫ﻋﻨﺪك ﻓﻲ‬
‫رﺳﻢ ﺑﻴﺎﻧﻲ ﻟﺴﻴﻨﺎرﻳﻮﻫﺎت‬
‫ﻣﻌﻨﺪوش اﻟﻤﴩوع‬
clone

Remote
Repository

Remote server
‫رﺳﻢ ﺑﻴﺎﻧﻲ ﻟﺴﻴﻨﺎرﻳﻮﻫﺎت‬
‫ﻣﻌﻨﺪوش اﻟﻤﴩوع‬
‫‪clone‬‬

‫ﻋﻨﺪو ‪ Repo‬و ﺑﻐﻰ‬


‫ﻳﺠﻴﺐ اﻟﺘﻐﲑات‬ ‫‪Remote‬‬
‫‪pull‬‬ ‫‪Repository‬‬

‫‪Remote server‬‬
‫رﺳﻢ ﺑﻴﺎﻧﻲ ﻟﺴﻴﻨﺎرﻳﻮﻫﺎت‬
‫ﻣﻌﻨﺪوش اﻟﻤﴩوع‬
‫‪clone‬‬

‫ﻋﻨﺪو ‪ Repo‬و ﺑﻐﻰ‬


‫ﻳﺠﻴﺐ اﻟﺘﻐﲑات‬ ‫‪Remote‬‬
‫‪pull‬‬ ‫‪Repository‬‬

‫ﻋﻨﺪو ‪ Repo‬و ﺑﻐﻰ‬


‫ﻳﺸﺎرك اﻟﺘﻐﲑات اﻟﲇ‬
‫دار‬ ‫‪push‬‬

‫‪Remote server‬‬
‫‪Issues‬‬

‫‪ :Issues‬اﻟﻤﺸﺎﻛﻞ ) ‪ ، ( Bugs‬اﻟﺘﺤﺴﻴﻨﺎت و اﻷﻓﻜﺎر اﻟﲇ ﻣﺘﻌﻠﻘﺔ ﺑﺎﻟﻤﴩوع‬

‫● أي واﺣﺪ ﻳﻘﺪر ﻳﻔﺘﺢ ‪issue‬‬


‫● ‪ issue‬ﻳﻤﻜﻦ ﻟﻴﻨﺎ ﻧﻌﻴﻨﻬﺎ ﻟﴚ واﺣﺪ )‪(Assignment‬‬
‫● ﻓﺎش اﻟﻤﺸﻜﻞ ﻛﻴﺘﺤﻞ ﻛﻨﺴﺪوﻫﺎ‬
‫‪Pull-request‬‬

‫‪:Pull-request‬‬

‫● ﻃﻠﺐ اﻟﺪﻣﺞ ) ‪ ( merge‬ﺑﲔ ﻓﺮع ) ‪ ( branch‬ﻵﺧﺮ‬


‫● ﻛﺘﻜﻮن ﻣﺘﻌﻠﻘﺔ ﻋﻤﻮﻣﺎ ﺑﴚ ‪issue‬‬
‫● ﻋﻨﺪﻫﺎ واﺟﻬﺔ ﻛﻨﺪﻳﺮو ﻓﻴﻬﺎ ﻣﺮاﺟﻌﺔ ﻟﻠﻜﻮد اﻟﻤﺮاد دﻣﺠﻪ و ﻧﺘﻨﺎﻗﺸﻮ‬
‫ﻓﻴﻪ‬

You might also like