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
● ﻋﻨﺪﻫﺎ واﺟﻬﺔ ﻛﻨﺪﻳﺮو ﻓﻴﻬﺎ ﻣﺮاﺟﻌﺔ ﻟﻠﻜﻮد اﻟﻤﺮاد دﻣﺠﻪ و ﻧﺘﻨﺎﻗﺸﻮ
ﻓﻴﻪ