Skip to main content

Command Palette

Search for a command to run...

Git Basic part 1

Updated
2 min readView as Markdown
Git Basic part 1
S

Site Reliability Engineer @ onenex.co

Git account မရှိသေးရင် GitHub, GitLab, Bitbucket တို့မှာ အခမဲ့ ဖွင့်လို့ရပါတယ်၊ ကျွန်တော်ကတော့ ဒီပို့မှာ GitHub နဲ့ပဲ အဓိက ပြောသွားမှာပါ။ တစ်ခုနဲ့ တစ်ခုတော့ UI နည်းနည်း ကွာပေမယ့် သုံးရမယ့် command တွေကတော့ အတူတူပါပဲ။

Git အကောင့်ရှိပြီဆိုရင် git ကို သုံးဖို့ git client ရှိဖို့တော့ လိုပါသေးတယ် သင့်စက်ထဲမှာ မရှိရင် ထည့်ထားလိုက်ပါ။
🐧Download for Linux
🍏Download for OSX
🪟Download for Windows

ရှိနေပြီးသား ပရောဂျက်ဖိုဒါမှာ git စသုံးမယ်ဆိုရင် ပရောဂျက် ဖိုဒါထဲမှာ terminal ဖွင့်ပြီး git init လို့ရိုက်လိုက်ရုံပါပဲ။ ကျွန်တော် အောက်မှာ ပြထားတဲ့ command တွေကို စမ်းရိုက်ကြည့်ပါ။

mkdir git-basic
cd git-basic
echo "Hello Git" > hello.md
echo "PONG" > ping.md
git init
git add ping.md
git status
git commit -m "added ping.md"

အပေါ်က command တွေကို ပြန်ပြောရမယ်ဆိုရင် git-basic ဆိုတဲ့ ဖိုဒါ ဆောက်လိုက်တယ်၊ အဲ့အထဲမှာ hello.md နဲ့ ping.md ဆိုပြီး နှစ်ဖိုင်ရေးလိုက်တယ်။

ပြီးတော့ အဲ့ ဖိုဒါထဲမှာ git init ဆိုပြီး git repository တစ်ခု တည်ဆောက်လိုက်တယ်။ git status ဆိုတာကတော့ working directory ထဲမှာ လက်ရှိ git အခြေအနေကို ဖေါ်ပြခိုင်းတာပါ။ အဲ့မှာ ကြည့်လိုက်ရင် hello.md နဲ့ ping.me ဆိုပြီး နှစ်ဖိုင်က untracked files တွေအဖြစ်ရှိနေကြောင်း တွေ့ရမှာပါ။

git add ping.md လို့ ရိုက်လိုက်ပြီးမှ git status ကို ထပ်ကြည့်မယ်ဆိုရင်တော့ ping.md ကို tracked new file အဖြစ် ဖေါ်ပြပြီး hello.md ကိုတော့ untracked file အဖြစ်ပဲ မြင်နေရအုံးမှာပါ။ ကျွန်တော်တို့ index ထဲထည့်ပြီးသား ping.md ကို head ထဲရောက်ဖို့အတွက် commmit ရေးပေးဖို့လိုပါတယ်။ commit ရေးဖို့အတွက် git commit -m "added ping.md" ဆိုပြီး ရိုက်လိုက်ရုံပါပဲ ။ အဲ့လိုရိုက်လိုက်တဲ့အခါမှာ git ကို အခုမှ စသုံးတာဆိုရင် ပုံထဲကလိုမျိုး ပေါ်လာနိုင်ပါတယ်။

ပုံထဲကလို ပေါ်လာရင်သူပြောထားတဲ့ command နှစ်ခုကို run ပေးလိုက်ပါ။ ကိုယ့်ရဲ့ အမည်နဲ့ အီးမေးကို ထည့်ပေးထားတော့မှ commit ရေးတာ ဘယ်သူလဲလို့ git က သိပြီး မှတ်တမ်းတင်ပေးထားနိုင်မှာပါ။ ဒီနေရာမှာ --global ဆိုတဲ့ option ကို ထည့်ရိုက်မယ်ဆိုရင် default author အဖြစ် မှတ်ထားမှာ ဖြစ်ပြီး --global မပါရင်တော့ လက်ရှိ repository မှာပဲ ဒီ အမည်နဲ့အီးမေးကို author အဖြစ် မှတ်ထားပေးမှာပါ။

# Example 
git config --global user.email "str@thixpin.me"
git config --global user.name "Soe Thura"

# or
git config user.email "str@thixpin.me"
git config user.name "Soe Thura"

Git config user ကို သတ်မှတ် ပြီးပြီဆိုရင်တော့ commit ပြန်ရေးကြည့်လို့ရပါပြီ။

git commit -m "added ping.md"
git status
git add .
git commit -m "second commit"
git log

git add . ဆိုတာက လက်ရှိ ပြောင်းလဲထားသမျှဖိုင်အကုန်လုံးကို index ထဲထည့်တာပါ။ ပြီးရင် git commit -m "second commit" လို့ရိုက်ပြီး ဒုတိယ commit ရေးခြင်းအားဖြင့် hello.me ကို head ထဲ ထည့်လိုက်နိုင်ပါတယ်။ နောက်ပြီး git log လို့ရိုက်ပြီး commit history ကို quick review အနေနဲ့ ကြည့်လို့ရပါတယ်။ git log ထဲက ပြန်ထွက်ချင်ရင် ကီးဘုတ်မှာ q ကို နှိပ်ပြီး ထွက်လို့ရပါတယ်။

အောက်ပုံကတော့ Git ရဲ့ အခြေခံ အလုပ်လုပ်ပုံ ပါပဲ ကျွန်တော်တို့ working dir ထဲမှာ ဖိုင်တွေပြင်တယ် ဖိုင်အသစ်တွေဆောက်တယ်၊ ပြီးသွားရင် git add ဆိုပြီး index ထဲထည့်တယ် Index က staging area အဖြစ် အလုပ်လုပ်တယ် stage change တွေကို commit လုပ်ပြီးသိမ်းလိုက်တော့ Head က ကိုယ်ရဲ့ နောက်ဆုံး commit ကို point ပေးတယ်။

Git နဲ့ ပတ်သက်ပြီး နောက် အပိုင်းတွေ ဆက်ရေးပေးပါအုံးမယ်၊ ကျွန်တော်က စာရေးနေကြသူမဟုတ်တော့ လိုအပ်တာတွေရှိရင်လည်း အားမနာတမ်း ဝေဖန်ပေးသွားလို့ရပါတယ်။

576 views

More from this blog

Difference Between Regional NAT Gateway and Zonal NAT Gateway

ဒီ post လေးထဲမှာတော့ Regional NAT Gateway နဲ့ Zonal NAT Gateway ကွာခြားချက်တွေကို နှိုင်းယှဉ်ပြသွားမှာဘဲ ဖြစ်ပါတယ်။ ပထဆုံးအနေနဲ့ NAT Gateway ဆိုတာ ဘာလဲ ဘာအတွက် လိုအပ်တာလဲဆိုတာကို အရင်ပြောပြပေးပါမယ်။ P

Jun 19, 20264 min read132
Difference Between Regional NAT Gateway and Zonal NAT Gateway

Infrastructure ကိုင်ပြီး အိပ်ရေးမပျက် ချင် လျှင် ဒါမျိုး Alarms လုပ် 🔥🔥🔥

High Level ရေးထားတာပါ ဒါပေမဲ့ လွယ်ပါတယ် ​ကိုယ့်မှာ AWS Infra တွေရှိတယ်ဆို တွေ့သမျှ metric တွေကို alarms တွေလုပ်ပြီး notification ယူမနေဘဲ တကယ် effective ဖြစ်တဲ့ metric တွေကိုမှ CloudWatch ရဲ့ alarm feature တွေနဲ့ ပေါင်းပြီး ပို့စေချင်ပါတယ်။ ​ဥပမာ prod...

Jan 17, 20263 min read253
Infrastructure ကိုင်ပြီး အိပ်ရေးမပျက် ချင် လျှင်  ဒါမျိုး Alarms လုပ် 🔥🔥🔥

How to connect On Premises Network and Cloud (AWS)? (Part-2)

ကိုယ့်ရဲ့ ‌data center (on-prem) network နဲ့ AWS ချိတ်ဆက်ဖို့ လိုလာပြီဆိုရင် ဘယ်လို ချိတ်ဆက်ကြမလဲ? အပိုင်း (၂) မှာ တော့ Direct connect အကြောင်းကို ဆွေးနွေး သွားမှာ ဖြစ်ပါတယ်။ အပိုင်း (၁) Site-to-site VPN အကြောင်းကို လေ့လာချင်ရင်တော့ အောက်ပါ link မှာ ...

Dec 20, 20253 min read280
How to connect On Premises Network and Cloud (AWS)? (Part-2)

How to connect On Premises Network and Cloud (AWS)? (Part-1)

ကိုယ့်ရဲ့ ‌data center (on-prem) network နဲ့ AWS ချိတ်ဆက်ဖို့ လိုလာပြီဆိုရင် ချိတ်ဆက်နိုင်တဲ့ နည်း (၂) နည်း ရှိပါတယ်။ 1. Site-to-Site VPN (Virtual Private Network) 2. Direct connect Site-to-Site VPN - On-prem network နဲ့ AWS resources တွေ ချိတ်ဆက်တဲ့...

Dec 12, 20252 min read312
How to connect On Premises Network and Cloud (AWS)? (Part-1)
M

Myanmar Technical Blog

110 posts

Cloud, Linux, DevOps, Docker, Security အစရှိတဲ့ နည်းပညာများ အကြောင်းကို မြန်မာလို ပြန်လည်မျှဝေပေးမယ့် Blog ပဲဖြစ်ပါတယ်ခဗျာ...