Orduithe Git Úsáideacha: Treoir Chuimsitheach

Seo liosta mionsonraithe d’orduithe úsáideacha Git, mar aon le samplaí léiriúcháin:

git init

Tosaigh stór Git nua i d'eolaire tionscadail.

Sampla:

$ git init  
Initialized empty Git repository in /path/to/your/project/.git/  

git clone [url]

Clón stór cianda ón bhfreastalaí go dtí do mheaisín áitiúil.

Sampla:

$ git clone https://github.com/yourusername/your-repo.git  
Cloning into 'your-repo'...  

git add [file]

Cuir comhad amháin nó níos mó leis an limistéar stáitse chun ullmhú do commit.

Sampla:

$ git add index.html  
$ git add *.css  

git commit -m "message"

Cruthaigh ceann nua commit leis na hathruithe a cuireadh leis an limistéar stáitsithe agus cuir do commit theachtaireacht san áireamh.

Sampla:

$ git commit -m "Fix a bug in login process"  
[main 83a9b47] Fix a bug in login process  
1 file changed, 5 insertions(+), 2 deletions(-)  

git status

Féach ar stádas reatha an stór, lena n-áirítear comhaid leasaithe agus an limistéar stáitsithe.

Sampla:

$ git status  
On branch main  
Changes not staged for commit:  
 (use "git add <file>..." to update what will be committed)  
 (use "git restore <file>..." to discard changes in working directory)  
        modified:   index.html  
  
no changes added to commit(use "git add" and/or "git commit -a")

git log

Taispeáin commit stair an stór.

Sampla:

$ git log
commit 83a9b4713f9b6252bfc0367c8b1ed3a8e9c75428(HEAD -> main)  
Author: Your Name <[email protected]>  
Date:   Mon Jul 13 12:34:56 2023 +0200  
  
    Fix a bug in login process  
  
commit 47f1c32798b7e862c4c69718abf6498255f1a3d2  
Author: Your Name <[email protected]>  
Date:   Sun Jul 12 18:42:15 2023 +0200  
  
    Add new homepage  

git branch

Déan liosta de na brainsí go léir sa stór agus marcáil an brainse reatha.

Sampla:

$ git branch  
* main  
  feature/add-new-feature  
  feature/fix-bug  

git checkout [branch]

Téigh go brainse eile sa stór.

Sampla:

$ git checkout feature/fix-bug  
Switched to branch 'feature/fix-bug'  

git merge [branch]

Cumaisc brainse eile isteach sa bhrainse reatha.

Sampla:

$ git merge feature/add-new-feature  
Updating 83a9b47..65c6017  
Fast-forward  
 new-feature.html| 10 ++++++++++  
 1 file changed, 10 insertions(+)  
 create mode 100644 new-feature.html  

git pull

Athruithe ó chianstór a fháil agus a chomhtháthú isteach sa bhrainse reatha.

Sampla:

$ git pull origin main  
From https://github.com/yourusername/your-repo  
* branch            main       -> FETCH_HEAD  
Already up to date.  

git push

Brúigh athruithe ón mbrainse reatha go dtí stór cianda.

Sampla:

$ git push origin main

git remote add [name] [url]

Cuir cianfhreastalaí nua le do liosta stórtha cianda.

Sampla:

$ git remote add upstream https://github.com/upstream-repo/repo.git

git fetch

Íoslódáil athruithe ó chianstórtha ach ná déan iad a chomhtháthú sa bhrainse reatha.

Sampla:

$ git fetch origin

git diff

Déan comparáid idir na hathruithe idir an limistéar stáitse agus na comhaid rianaithe.

Sampla:

$ git diff

git reset [file]

Bain comhad ón limistéar stáitse agus cuir ar ais go dtí an staid roimhe é.

Sampla:

$ git reset index.html

git stash

athruithe neamhthiomanta a shábháil go sealadach chun oibriú ar bhrainse eile gan iad a dhéanamh.

Sampla:

$ git stash
Saved working directory and index state WIP on feature/branch: abcd123 Commit message

git remote -v

Liostaigh na cianfhreastalaithe agus a seoltaí url.

Sampla:

$ git remote -v  
origin  https://github.com/yourusername/your-repo.git(fetch)  
origin  https://github.com/yourusername/your-repo.git(push)  
upstream        https://github.com/upstream-repo/repo.git(fetch)  
upstream        https://github.com/upstream-repo/repo.git(push)