Anan akwai cikakken jerin umarnin Git masu amfani, tare da misalan misalai:
git init
Fara sabon ma'ajiyar Git a cikin kundin tsarin aikin ku.
Misali:
$ git init
Initialized empty Git repository in /path/to/your/project/.git/
git clone [url]
Rufe ma'ajiyar nisa daga uwar garken zuwa na'ura ta gida.
Misali:
$ git clone https://github.com/yourusername/your-repo.git
Cloning into 'your-repo'...
git add [file]
Ƙara fayiloli ɗaya ko fiye zuwa wurin tsarawa don shirya don commit.
Misali:
$ git add index.html
$ git add *.css
git commit -m "message"
Ƙirƙiri sabo commit tare da canje-canjen da aka ƙara zuwa wurin tsarawa kuma haɗa commit saƙon ku.
Misali:
$ 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
Duba halin yanzu na ma'ajiyar, gami da fayilolin da aka gyara da wurin tsarawa.
Misali:
$ 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
Nuna commit tarihin ma'ajiyar.
Misali:
$ 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
Jera duk rassan da ke cikin ma'ajiyar kuma yi alama reshe na yanzu.
Misali:
$ git branch
* main
feature/add-new-feature
feature/fix-bug
git checkout [branch]
Canja zuwa wani reshe a cikin ma'ajiyar.
Misali:
$ git checkout feature/fix-bug
Switched to branch 'feature/fix-bug'
git merge [branch]
Haɗa wani reshe zuwa reshe na yanzu.
Misali:
$ 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
Dauke da haɗa canje-canje daga wurin ajiya mai nisa zuwa reshe na yanzu.
Misali:
$ git pull origin main
From https://github.com/yourusername/your-repo
* branch main -> FETCH_HEAD
Already up to date.
git push
Tura canje-canje daga reshe na yanzu zuwa wurin ajiya mai nisa.
Misali:
$ git push origin main
git remote add [name] [url]
Ƙara sabon uwar garken nesa zuwa jerin wuraren ajiyar ku na nesa.
Misali:
$ git remote add upstream https://github.com/upstream-repo/repo.git
git fetch
Zazzage canje-canje daga wuraren ajiya mai nisa amma kar a haɗa cikin reshe na yanzu.
Misali:
$ git fetch origin
git diff
Kwatanta canje-canje tsakanin wurin tsarawa da fayilolin da aka sa ido.
Misali:
$ git diff
git reset [file]
Cire fayil daga wurin tsarawa kuma mayar da shi zuwa jihar da ta gabata.
Misali:
$ git reset index.html
git stash
ajiye canje-canje marasa aiki don aiki akan wani reshe na daban ba tare da yin su ba.
Misali:
$ git stash
Saved working directory and index state WIP on feature/branch: abcd123 Commit message
git remote -v
Jera sabar nesa da adireshin url ɗin su.
Misali:
$ 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)