Git - A simple step into Deep world!

Hello all again,
       ဒီတခေါက် sharing လုပ်ပေးချင်တာကတော့ git အကြောင်းပါ Git ကို developing, software သမားတွေဆို မစိမ်းလောက်ပါဘူး. ကျောင်းတက်တုန်းက သေချာ မလုပ်ခဲ့တာတွေကြောင့် ကိုယ်အလုပ်ခွင်ထဲရောက်တဲ့အခါမှာ git ကို နားလည်အောင် တော်တော် လေ့လာခဲ့ရတယ်.. repositoryတော်တော်များများလည်း ကိုယ်လုပ်လို့ ပျက်စီးခဲ့ပါတယ် 😃 seniors တွေဆီကလည်း အဆူတွေခံရပေါ့ 😬

     Ok . so အရင်ဆုံး GITရဲ့ အဓိပါယ်လေး..Google မှာ ခေါက်လိုက်ရင်တော့ တွေ့ရမှာလေးပေါ့..
Git  is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files.
GITကိုနှစ်မျိုး အသုံးပြုလို့ရတယ် .
https://git-scm.com/downloads
Windows မှာဆိုတော့ ပိုပီး simple တယ် gitbash. သူက UI လေးနဲ့ဆိုတော့.


So ဒီsharing sessionမှာ ကိုယ်က Linuxသမားတစ်ယောက် ဖြစ်နေတော့ Step by step how to use git in linux ကို ပိုအလေးပေးပြောသွားမိရင် ခွင့်လွှတ်ပါ 😬
  •  အရင်ဆုံး ကိုယ့်terminalမှာ git  ဒါမှမဟုတ်
  •  $ man git  ဆိုပီး ရိုက်ကြည့်ပါ (If there is no GIT installed, please check here to install -> https://git-scm.com/download/linux)
အရင်ဆုံး Git မှာ ကိုယ့်အကြောင်းကို မိတ်ဆက်ပေးတာကနေ စတာပေါ့. git repository တစ်ခုကို clone မလုပ်ခင် အလွယ်ဆုံးလုပ်သင့်တဲ့ အရာလေးပါ.

မ clone ခင်မှာ အရင်ဆုံး  ssh key ကို  generate လုပ်ပေးရမည် 
You can check under SSH and GPG keys of your git hub account's settings.

$ git config --global user.name "Your Name Here"
$ git config --global user.email you@youdomain.example.com

ကိုယ်က github.com မှာ လိုချင်တဲ့ repository တခုကို ကိုယ့်ရဲ့localထဲ clone ချင်ပီ အရင်ဆုံး ကိုယ်clone ချင်တဲ့ repositoryရဲ့ SSH ကို ကူးမယ်.


$ git clone git@github.com:swezphyo/python_castle.git
ဒါဆိုရင် ကိုယ့်localထဲ ဒီrepoလေး cloneပီးသားဖြစ်သွားပီ.

အခြေခံအားဖြင့် git commands တွေက
$git init -  ပီးပီဆို ကို စသူံးတော့မှာ ဆိုပီး ‌ြေကညာရပါတယ်

$ git status - ကိုယ်က repoရဲ့ ဘယ် branchကို ရောက်နေလဲ ကြည့်ရင် git statusနဲ့ သွားရပါတယ်
git status ကို အမြဲရိုက်ကြည့်ဖို့ အားပေးပါတယ်

Managing Branches

Branch ေ တွ ပီး development တွေ စတင်မယ် $ git branch -a <branch_name>

ပုံမှန်အားဖြင့် project တစ်ခုကိုလုပ်ပီဆို master branch ကို မထိကြပါဘူး
Testing, development အားလုံး freezeဖြစ်မှ developerတွေက ကိုယ့်ဆိုင်ရာဆိုင်ရာ branchတွေကနေ masterကို merge requestလုပ်ကြပါတယ်
Branch ခွဲပီးပီဆို အဲbranchကို သွားမယ်ဆို $ git checkout  <branch_name>

Developing တွေလုပ်ပီး ကိုယ်branchတွေကို ပြန်ဖျက်မယ်ဆို နှစ်နည်းလုပ်လို့ရပါတယ်

ဒီမှာ d အသေးနဲ့က ပုံမှန် ဘာerrorမှ မရှိလို့ ဒီbranchကို ဖျက်သိမ်းမယ်ဆိုရင် သုံးရပီး
$ git branch -d <branch_name>

D အကြီးကျတော့ by forceနဲ့ ဒီbranchကို ဖျက်ဖို့
$ git branch -D <branch_name>

Adding file to repository

Branchတွေခွဲပီးပီဆိုတော့ ကိုယ့်developingတွေ လုပ်ပီး ပြန်ပေါင်းမယ်ဆို
$ git add = add ur files to master
Add လုပ်ရာမှာလည်း ၁fileချင်းဆီ add မယ်ဆို file_nameနဲ့ add ပေးပီး
$ git add (file you want to add)
အကုန်လုံးကို addမယ်ဆိုရင်ဖြင့် git add ဆိုပီး သွားပေးရပါတယ်
$ git add .
Addပီးပီဆို commitလုပ်ရပါမယ်

$ git commit -m "<commit_msg>"

အပေါ်က steps တွေ အကုန်ပီးပီဆိုရင် pushလုပ်ဖို့ အတွက် နောက်ဆုံး အနေနဲ့ git status တချက်ပြန်ကြည့်ပီး ကိုယ်addဖို့. Branchမှန်လား ကြည့်ပေးပီး,မှန်တယ်ဆို push လုပိပေးပီ master ကို merge requestတင်လို့ရပါပီ

$ git push -u origin

ကိုယ်ရောက်နေတဲ့ remote branchကိ ု codes pushချင်ရ တော့
$ git push origin <remote_branch>

Master branchက ကိုယ့်codesတွေကို acceptလုပ်ပီး mergeပီးသားကို ကိုယ့်localဆီပြန်ဆွဲမယ်ဆို .

$ git checkout master
$ git status

$git fetch
$ git pull


  ကိုယ် လုပ်ထားတဲ. commits's history (log ) ပြန် ကြည့်ချင်ဆို
$ git log 
or 
$ git log --pretty 


ဒီstepsလေးတွေနဲ့ဆို ကိုယ်က ဒီrepo ကို clone, branchခွဲ, developmentတွေလုပ်, ပီးရင် masterနဲ့ ပြန်merge, ပြန်pull စတဲ့ အခြေခံ git လုပ်ပုံလုပ်နည်းလေးကို နားလည်မယ်လို့ မျှော်လင့်ပါတယ်


ကျေးဇူးတင်ပါတယ်

Welcome from any feedbacks, 😁



















Comments

Popular posts from this blog

Using Zabbix Inventory Script for AWX Ansible Tower Inventory

cisco csr1000v ios upgrade or downgrade

Python3 - Basic Knowledge of using Dictionary