မူရင်း Git Repository file ကို မိတ္တူပွားခြင်း (Clone လုပ်ခြင်း)

(မိတ္တူမပွားခင် Tutorial 1 တွင် ပြထားသည့်အတိုင်း git init ဖြင့် Git file ပြုလုပ်ရမည်)
*Clone မလုပ်ခင် လက်ရှိဝင်၇ောက်ထားသည့် Project မှ cd ဖြင့် ထွက်ပါ.

git clone OriginFile_Location&Name CloneFile_Location&Name
git pull origin master
git push origin master
git init --bare
git commit -am "your comment"
git remote show origin
git remote remove origin
git remote add origin github_Link-
Github မှ Clone ခြင်း
git clone github_link NewLocation&Name

a. Clone လုပ်ခြင်း
git clone OriginFile_Location&Name CloneFile_Location&Name
e.g. git clone Desktop/Project Desktop/NewProject
(Desktop ရှိ Project အမည်ဖြင့်ဖိုင်ကို Desktop တည်နေရာတွင်ပင် NewProject အမည်ဖြင့် Clone/မိတ္တူပွားသည်)

git clone OriginAddress သာ ပေးပါက မူရင်းဖိုင်အမည်ဖြင့် clone ပွားမည်။
e.g. git clone /opt/lampp/htdocs/project
project အမည်အတိုင်း clone ပွားမည်။

*File သည် Home တွင်ရှိပါက Desktop/ နေရာတွင် ./ dot ဖြင့် တည်နေရာညွှန်းရသည်။

b. Clone Repository မှ git pull လုပ်ခြင်း

git pull (မူရင်း Git Repository File ရှိ ပြုပြင်ပြောင်းလဲထားတဲ့ code တွေကို Clone Repository က ရယူခြင်းဖြစ်သည်)

git pull origin master
* မူရင်း Git Repository ရှိ master page မှ ပြုပြင်ထားတဲ့ code တွေကို update ရယူမည်။
origin => မူရင်း Git Repository ကို ဆိုလိုသည်။
master => မူရင်း Git Repository ရှိ master page ကိုဆိုလိုသည်။

**Clone လုပ်ထားသောကြောင့် မူရင်း Git Repository နှင့် Clone Git Repository သည် auto ချိတ်ဆက်နေသည်။

Clone ၏ မူရင်း Git Repository ကို ကြည့်ရှုလိုပါက:
clone ဖိုင်သို့သွားပါ..
git remote show origin


Note: ဤနည်းသည် မူရင်း Git Repository နှင့် Clone Repository နှစ်ခုကြား ချိတ်ဆက်မှုဖြစ်သည်။
မူရင်း Git Repository ၏ ပြုပြင်ပြောင်းလဲထားသည့် code တွေကို Clone က လှမ်းယူ (pull) ၍ ရသော်လည်း၊ Clone Repository ၏ ပြုပြင်ပြောင်းလဲမှုတွေကို မူရင်းက လှမ်းယူ၍ မရပါ။ ထို့အတူ Clone ကလည်း မူရင်း Git Repo သို့  လှမ်းပေး (push) လို့မရပါ။ 

____________________________________________________________________
2. Git Bare Repository ကို ဘုံ/ကြားခံထား၍ Develper ၂ ယောက်နှင့်အထက်ကြား code များကို  ပေးပို့ခြင်း (push)၊ လှမ်းယူခြင်း (pull)



a. Git Bare Repositroy တည်ဆောက်ခြင်း
git init --bare

*Git Bare Repository ဆိုတာ version တွေကိုသာ မှတ်တမ်းတင်ခြင်းဖြစ်ပြီး၊ Soure code တွေကို မှတ်တမ်းမတင်ပါ။ 

Git Bare Repository ကို Clone ဖိုင် နှစ်ခုလုပ်ပါ။

Clone Repository တစ်ခုမှ update လုပ်ပြီး အချက်အလက်ကို Git Bare Repository သို့ ပေးပို့ပါ။
git push origin master
*Origin (Git Bare Repository) ရှိ master page သို့ အချက်အလက်များပေးပို့ခြင်း

အခြားClone Repository က update လုပ်ပြီးသောအချက်အလက်ကို Git Bare Repository မှ ရယူပါ။
git pull origin master

ဤသို့ git pull, git push နည််းဖြင့် Developers များ အကြား အချက်အလက်များ အပြန်အလှန်ပေးပို့နိုင်သည်။

b. git pull, git push လုပ်ရာတွင် Conflict ဖြစ်ခြင်း
Delevloper ၂ ယောက် code များကို တစ်ပြိုင်တည်း ရေးမိပြီး၊ pull, push လုပ်သည့်အခါ error, confict တွေဖြစ်မည်။

*နောက်ဆုံး update ကို မရယူဘဲ push မိပါက error တက်မည်။
*နောက်ဆုံး update ကို မရယူဘဲ ပြင်ဆင်ပြီးကာမှ pull မိပါက error ပြမည်။

ဒါကြောင့် မ pull ခင် updated code သို့ File တွေကို commit အရင်လုပ်ပါ။

git commit -am "your comment"
*File သည် commit လုပ်ပြီးဖြစ်ကာ အတွင်းရှိ code ကိုသာ commit လုပ်ရန် လိုအပ်ပါက  -am ကို တိုက်ရိုက်လုပ်နိုင်သည်။ (git add . ကို မရေးလိုသောကြောင့်ဖြစ်သည်။)


ထိုအခါ Conflict ဖြစ်နေသည့် code ၂ ခုကို နှိုင်းယှဥ်ပြပြီး ပြင်ဆင်ခိုင်းမည်။ တစ်ခုရွေးကာ commit လုပ်ပေးပါ။

<<<<<<< HEAD
=======
hi
>>>>>>> a66c8d3d10bc015d10d2552332121dbdfd83aa4c


____________________________________________________________________

3. Github ကို ကြားခံ Repository အဖြစ်ထားကာ Source code များ ရယူခြင်း၊ ပေးပို့ခြင်း။

- Github တွင် New Repository တည်ဆောက်ပါ။

echo "# sample" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/Shine-Htet/sample.git
git push -u origin master

- Clone Repository နှင့် ချိတ်ဆက်ထားသော Origin Repository ကို ကြည့်ရှုခြင်း
git remote show origin

- Clone Repository နှင့် ချိတ်ဆက်ထားသော Origin Repository နှင့် ချိတ်ဆက်မှုဖြုတ်ခြင်း
git remote remove origin

* ပထမချိတ်ဆက်ထားတဲ့ မူရင်း Repository နှင့် မဆိုင်တော့ဘဲ သီးခြားဖြစ်သွားမည်။
- သင့် computer ရှိ Git Repository ကို Github နှင့် ချိတ်ဆက်ခြင်း
git remote add origin github_Link
e.g. git remote add origin https://github.com/Shine-Htet/sample.git

README.md ကို သင့်ကွန်ပျူတာရှိ Git Repository တွင် မဖြစ်မနေထားရှိပေးပါ။
add and commit လုပ်ပေးပါ။

- Push & Pull
git push origin master
git pull origin master
username နှင့် Password သာ ပိုလာမည်။ အပေါ်နှင့် အတူတူပါ။

- Github မှ Clone ခြင်း
git clone github_link NewLocation&Name
e.g. git clone https://github.com/Shine-Htet/sample.git Desktop/Project1


Git Source Code Management System Tutorial 1 https://shineyjvlog.blogspot.com/2019/12/git-tutorial-1.html
Source: 
Ei Maung