DEV Community

Kudrat
Kudrat

Posted on

Working on Github

Github nima?

Umuman olganda Github haqida gaplashadigan bo'lsak,u source control vebsayt hisoblanadi.Xo'sh source control vebsayt nima?
Siz turli xil rasm yoki fayllaringizni Google Drive,OneDrive,DropBox singari cloud dasturlarda saqlaysiz.Xuddi shunday siz yozgan kodlarni ham saqlash uchun Github ishlatiladi.
Bundan tashqari Git degan tool ham bor va u kodni versiyasini boshqarish uchun ishlatiladi.

Advantage of Github

Agarda sizda katta bir loyiha ustida ishlayotgan bo'lsangiz va version control bo'lmasa,biror xatolik yuz beradigan vaziyatlarda,siz oldingi kodingizni bevosita o'zgartira olmaysiz.Ya'ni u kodni to'girlash uchun,undan keyingi barcha kodlaringizni o'chirib chiqishingiz zarur bo'ladi.
Git orqali bu muammoni yechimi bor.Siz har bir pageni tugatish mobaynida bayroq qo'yib ketasiz ya'ni commit qilib ketasiz.Va bir dona komanda orqali bir necha qadam oldindagi sahifaga hech qanday kodlarni o'chirmasdan o'tib olishingiz mumkin.
Yana bir afzalliklaridan biri shuki,agarda siz bitta loyiha ustida bir necha kishi ishlayotgan bo'lsangiz codelaringizni almashish ishlash uchun ham juda qulay.

Image description

Fork repository

Dastlab fork qilmoqchi bo'lgan repositoryga o'tasiz va quyidagi Fork tugmasini bosing

Image description
So'ngra qaysi repositoryga fork qilmoqchi ekanligingizni ko'rsatish lozim.
Image description

Bu jarayon tugashini biroz kutamiz va jarayon tugagach siz ushbu repositoryni clone qilishimiz kerak.Clone qilish uchun siz o'z sahifangizdagi code yozuvi ustiga bosasiz.Va quyidagi havolani ko'chirib olasiz.

Image description

Havolani ko'chirib olgach,Terminal oynasini ochgan holda

git clone https://github.com/author/repo
Enter fullscreen mode Exit fullscreen mode

ushbu komandani yozish kifoya.Keyin yangi branch yaratib olamiz

Image description

O'zimizni branchimizga o'tganizmizdan so'ng o'zgarishlarni amalga oshiramiz.O'zgarishlar kiritib bo'lgandan keyin

git commit -m "descriptive commit message"
Enter fullscreen mode Exit fullscreen mode

komandasi orqali commit qilamiz.
So'ngra

git push origin HEAD
Enter fullscreen mode Exit fullscreen mode

komandasi orqali repositoryimizga push qilamiz.
Undan keyin mana shu oynaga duch kelamiz

Image description
va create&pull request tugmasini bosamiz va quyidagi oynaga guvoh bo'lamiz.

Image description
va create&pull request so'rovini jo'natamiz.

Github Commands

Command Description
git init Initialize a local Git repository
git clone ssh://git@github.com/[username]/[repository-name].git Create a local copy of a remote repository
git status Check status
git add [file-name.txt] Add a file to the staging area
git add -A Add all new and changed files to the staging area
git commit -m "[commit message]" Commit changes
git rm -r [file-name.txt] Remove a file (or folder)
git branch List branches (the asterisk denotes the current branch)
git branch -a List all branches (local and remote)
git branch [branch name] Create a new branch
git branch -d [branch name] Delete a branch
git push origin --delete [branch name] Delete a remote branch
git checkout -b [branch name] Create a new branch and switch to it
git checkout -b [branch name] origin/[branch name] Clone a remote branch and switch to it
git branch -m [old branch name] [new branch name] Rename a local branch
git checkout [branch name] Switch to a branch
git checkout - Switch to the branch last checked out
git checkout -- [file-name.txt] Discard changes to a file
git merge [branch name] Merge a branch into the active branch
git merge [source branch] [target branch] Merge a branch into a target branch
git stash Stash changes in a dirty working directory
git stash clear Remove all stashed entries
git push origin [branch name] Push a branch to your remote repository
git push -u origin [branch name] Push changes to remote repository (and remember the branch)
git push Push changes to remote repository (remembered branch)
git push origin --delete [branch name] Delete a remote branch
git pull Update local repository to the newest commit
git pull origin [branch name] Pull changes from remote repository
git remote add origin ssh://git@github.com/[username]/[repository-name].git Add a remote repository
git remote set-url origin ssh://git@github.com/[username]/[repository-name].git Set a repository's origin branch to SSH
git log View changes
git log --summary View changes (detailed)
git log --oneline View changes (briefly)
git diff [source branch] [target branch] Preview changes before merging

Top comments (0)