Version Control System (VSC) ကို Source Code Management System (SCM) လို့ ခေါ်သလို Revision Control System လို့လည်း ခေါ်ကြပါတယ်။
2 Jan 2020


touch index.html 
echo 'Hello, world!' > index.html

git log --pretty=oneline -3
git log --pretty=format:"&h - &an, &ar : &s" 
git log --pretty=format:'&h &s &d'


git tag -d v1

git checkout -b NewBranchName
git branch -d BranchNamegit branch -a
git remotegit remote show origin


git remote add RepositoryName RepositoryAddress
git pull thiha master 
git clone --bare RepositoryAddress
git commit --amend -am "Commit comment"
git reset --hard versionID


Software version
0.1.0 => 0.1.1,
0.1.20.2.0 => 0.2.1, 0.2.2
1.0.0 => 1.0.1, 1.0.2





Version Control System (VSC) မှာ versionMaster, Branch တွေပါဝင်ပါတယ်။
- Master နဲ့ Branch ကြား အပြန်အလှန်ကူးပြောင်း အလုပ်လုပ်နိုင်အောင် စီမံပေးပါတယ်။
- အမှားအယွင်းတစ်စုံတစ်ရာရှိခဲ့ရင် အရင် versionတွေကို ပြန်လည်ရယူနိုင်တယ်။
- Developer တွေရေးသားထားတဲ့ Source code တွေကိုလည်း ပေါင်းစပ်ပေးတယ်။

Version Control System (VSC) ၂ မျိုး
Centralized VCS vs. Decentralized/Distributed VCS

Centralized VCS
Source Code Repository ကို Central Server တစ်ခုတွင် ထားရှိပြီး Developer တွေက working copy ရယူပြီး အလုပ်လုပ်ကြခြင်းဖြစ်သည်။

VCS Terminologies (VCS အခေါ်အဝေါ်များ)
Version – Source Code ကို ပြင်ဆင်ပြီး မှတ်တမ်းတင်သိမ်းဆည်းလိုက်ခြင်း။
Commit – Source Code, New file တွေကို version သစ်အဖြစ် မှတ်တမ်းတင်သည့် လုပ်ဆောင်ချက်။
Change – ပြင်ဆင်ထားတဲ့ code နဲ့ နောက်ဆုံး commit လုပ်ထားတဲ့ version တို့ အကြား ခြားနားချက်။
Branch – မူလ code base ကို မူပွားပြီး ခွဲထွက်ခြင်း။
Master - မူလ Code Base ကို Master သို့ Trunk လို့ခေါ်ပါတယ်။ (Master Code Base)
Merge – Branch ရှိ Source code ကို Master သို့ အခြား Branch တစ်ခုနှင့် ပေါင်းစပ်ခြင်း။
Repository – Version အားလုံးနဲ့ Branch အားလုံးကို စုစည်းထားတဲ့ Code baseကို ခေါ်ဆိုခြင်းဖြစ်သည်။
Checkout – Central Source Server ရှိ Update version သို့ version ထဲက တစ်ခုခုကိုသာ ရယူခြင်း။
Clone – Central Source Server ရှိ Repositoryတစ်ခုလုံးကို မိမိ local computer သို့ မူပွားယူခြင်း။
HEAD – နောက်ဆုံး commit, နောက်ဆုံး version ကို ညွှန်းဆိုသည့် Keyword
tag – version ၏ အမည်ကို မိမိနှစ်သက်သည့် အမည် ပြန်ပေးခြင်း။
conflict – မိမိ၏ ပြင်ဆင်ထားသည့် code ဖိုင်နှင့် Server ပေါ်ရှိနောက်ဆုံး version code ဖိုင် ပြင်ဆင်မှု ဆင်တူနေသည့်အခါ Conflict ဖြစ်သည်။
Resolve – ထို့သို့ conflict ဖြစ်နေသည့် ဖိုင် ၂ခု မှ တစ်ခုကို ရွေးချယ်ပြီး commit လုပ်သည့်အခါ resolve ဖြစ်သွားသည်။
delta compression – version သစ်အဖြစ် မှတ်တမ်းတင်သည့်အခါ Code Base တစ်ခုလုံးကို ထပ်မသိမ်းတော့ဘဲ၊ ကွာခြားသည့် Changes တွေကို သာ သိမ်းဆည်းခြင်း။

Git installation
sudo apt-get install git-core

Git install လုပ်ပြီးသည့် git စတင်အသုံးပြုနိုင်ရန် အသုံးပြုမည့်သူ၏ နာမည်နှင့် Email ကို Configuration ဖိုင်တွင် အောက်ပါအတိုင်းထည့်ပေးရသည်။

git config --global user.name "shinehtet"
git config --global user.email "shinehtet@gmail.com"

Terminal မှ တစ်ဆင့် Git Repository တွင် ဖိုင်အလွတ်တည်ဆောက်ခြင်း
touch fileName
e.g. touch index.html
Git Repository တွင် index.html ဖိုင်တည်ဆောက်လိုက်သည်။
*touch Command က ဖိုင်တည်ဆောက်ခြင်းဟု မှတ်ယူပါ။

Terminal တွင် echo command အသုံးပြု၍ index.html တွင် ပြင်ဆင်ခြင်း
echo 'Hello, world!' > index.html
____________________________________________________________________
Git log Format Style
git log --pretty=oneline -3
-3 option သည် Commit သုံးခုသာ ကြည့်ရှုမည်ဖြစ်သည်။

81f48dc2faddcd42b0c479f53db522b64dd146ec Added app.js
08582cf9e218e12b74ff24711692ba2efea936dd Merge with conflict resolve
91478702aebe0fe49d667316b11c6fe4bc50062f Updated script.js in beta

git log --pretty=format:"&h - &an, &ar : &s"
e.g output
11bf458 - Ei Maung, 3 hours ago : First commit

(&h Placeholder - Short Commit Hash (Version ID)
&an - Author Name,
&ar - Author Date Relative
&s - Commit Comment Subject)


git log --pretty=format:'&h &s &d'
e.g.
f76103d Updated index.html (HEAD, master)
11bf458 First commit (tag: v1)


*&d ဆိုတဲ့ placeholder က Reference Name ကို ညွှန်းပါတယ်။ (HEAD, master) နှင့် (tag: v1) သည် Reference Name များဖြစ်သည်။
*Commit Hash သည် ပုံမှန်အားဖြင့် စာလုံး ၄၀ ရှိသည်။ Commit Hash သည် စာလုံး ၄၀ ကို မဖော်ပြတော့ဘဲ ရှေ့ ၇ လုံးကိုသာ ဖော်ပြမည်။

________________________________________________________________

-d option=> delete ပယ်ဖျက်ခြင်း
မိမိပေးထားသည့် tag ကို -d option ဖြင့် ဖျက်ခြင်း
git tag -d v1
11bf458 First commit (tag: v1) => 11bf458 First commit
မိမိ Reference လုပ်ထားတဲ့ tag ကို ပယ်ဖျက်ခြင်း

git checkout -b NewBranchName
e.g. git checkout -b ShineHtet

command သည် shortcut command ဖြစ်သည်။
git branch ShineHtet နှင့် git checkout ShineHtet ကို ပေါင်းစပ်ထားခြင်းဖြစ်သည်။ ဆိုလိုသည်မှာ Branch တည်ဆောက်ပြီး Branch သို့ Switch ပြောင်းပြီးသားဖြစ်သွားမည်။

-d option = branch ကို ပယ်ဖျက်ခြင်း
git branch -d BranchName
e.g. git branch -d ShineHtet
ShineHtet အမည်ရှိ Branch ကို ပယ်ဖျက်သည်။

git branch -a
Clone လုပ်ပြီးသည့်အခါ ထို Clone တွင် Version အားလုံးပါဝင်လာသော်လည်း၊ Branch အနေဖြင့် master branch တစ်ခုသာ ပါလာမည်။
ဒါကြောင့် -a Option ဖြင့် Branch ကို ညွှန်းထားသည့် အညွှန်းတွေကို ကြည့်ရှုရမည်။

git branch -a

* master
remotes/origin/HEAD -> origin/master
remotes/origin/beta
remotes/origin/master

Branch တွေကို တွေ့ရှိသည့်အခါ checkout ဖြင့် Switch ပြောင်းနိုင်ပါသည်။
git checkout beta


git pull origin master
git pull အဓိပ္ပါယ်က git fetch နဲ့ git merge ကို ပေါင်းစပ်ထားခြင်းဖြစ်သည်။
git fetch – မူရင်း Repository မှ update တွေကို ရယူခြင်း
git merge – ထိုနောက် ထို update တွေကို clone တွင် ပေါင်းစပ်ခြင်း



git remote
origin
*remote command ဖြင့် အညွှန်းကြည့်ရှုခြင်း။ လောလောဆယ် origin အမည်ဖြင့် အညွှန်းတစ်ခုသာ တွေ့ရမည်။

git remote show origin
* remote origin
Fetch URL: /opt/lampp/htdocs/project
Push URL: /opt/lampp/htdocs/project

Repository တစ်ခုမှာ တစ်ခုထက်ပိုတဲ့ Remote အညွှန်းတွေ ရှိနေနိုင်ပါတယ်။

git remote add
git remote အညွှန်းတစ်ခု ထပ်ထည့်ခြင်း

git remote add RepositoryName RepositoryAddress
git remote add thiha /var/www/project

thiha ဆိုသည့် remote အညွှန်းကို ထပ်ထည့်ခြင်းဖြစ်သည်။

git pull thiha master
thiha master code base မှ update များ ရယူခြင်း။

remove option
git remote remove reomteName
e.g. git remote remove thiha
thiha အညွှန်းကို ပယ်ဖျက်ခြင်း


clone --bare command ဖြင့် repository ကို clone မူပွားပြီး၊ bare repository အဖြစ်ဖန်တီးခြင်း
git clone --bare RepositoryAddress
e.g. git clone --bare /opt/lampp/htdocs/project

--amend Option (Commit ကို ပြန်လည် ပြင်ဆင်လိုခြင်း)
git commit --amend -am "Commit comment"

git reset
အရင်က Commit တွေကို ပယ်ဖျက်ခြင်း
git reset --hard versionID
e.g. git reset --hard b7ab351
VersionID b7ab351 နောက်ပိုင်း commit တွေပျက်သွားမည်


Software Versioning - Software version အမည်ပေးခြင်း။
စတင်စမ်းသပ်အသုံးပြုလို့ရသည့်အဆင့် - 0.1.0
0 = Major Version, 1 = Minor Version, 0 patch version
အမှားပြင်ဆင်ချက်ရှိလာရင် - 0.1.1, 0.1.2 စသဖြင့်

နောက်ထပ်ဖြည့်စွက်လုပ်ဆောင်ချက်အချက် ဖြည့်စွက်လို့ ပိုပြည့်စုံလာတဲ့အဆင့် - 0.2.0
ဖြည့်စွက်မှုတွေရှိလာတိုင်း - minor version နံပါတ်တိုးလာမယ်...
အမှားပြင်ဆင်ချက်ရှိလာရင် - 0.2.1, 0.2.2 စသဖြင့်

နောက်ဆုံးအများအသုံးပြုနိုင်ဖို့ ကြေငြာနိုင်လောက်အောင်ပြည့်စုံလာပြီဆိုရင် - 1.0.0

Major version နံပါတ်တိုးသွားမယ်။

Git ကို Command line က မသုံးပဲ user interface UI software တွေကလည်း သုံးနိုင်ပါသည်။