# Git Basic part 1

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

Git အကောင့်ရှိပြီဆိုရင် git ကို သုံးဖို့ git client ရှိဖို့တော့ လိုပါသေးတယ် သင့်စက်ထဲမှာ မရှိရင် ထည့်ထားလိုက်ပါ။  
🐧[Download for Linux](http://git-scm.com/book/en/Getting-Started-Installing-Git)  
🍏[Download for OSX](http://git-scm.com/download/mac)  
🪟[Download for Windows](https://gitforwindows.org/)

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

```bash
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 ကို အခုမှ စသုံးတာဆိုရင် ပုံထဲကလိုမျိုး ပေါ်လာနိုင်ပါတယ်။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1678546570357/c11501c0-0656-48c3-b456-fdfb3edc149d.png align="center")

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

```bash
# 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 ပြန်ရေးကြည့်လို့ရပါပြီ။

```bash
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 ကို နှိပ်ပြီး ထွက်လို့ရပါတယ်။

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1678548446592/cbe8ebd3-4070-474a-b4f6-39f9cd2f505b.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1678555682556/8752ccb3-c7fd-4f27-ab5e-afa78168f088.png align="center")

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