GIT - Bogdan Stashchuk

1. Shell commands

-> mkdir - make directory

-> ls - list files and directories

-> cd - change directory

-> . - alias of the current directory

-> .. - alien of the parent directory

-> pwd - prints path for the current directory

-> open . - opens folder

-> touch - create new file

-> > - write to the file

-> >> - append to the file

-> cat - list content of the file

-> nano - edit file

-> echo - print to terminal

-> man - help on specific command

-> rm - remove files and directories


2. How git works under the hood

-> git init - create new git repository

-> git add . - move file from untracked or modified stage to staged stage

-> git commit -m "message" - move file from staged stage to unmodified stage

-> if we change any file that is already tracked it will change its state to modified

-> git status - we see status of files

-> git rm --cached text3.txt - onstage file, remove file to untagged area

 

3. Git branches and Head

-> git add. - move files from working directory to staging area

-> git commit -m "message" - move files from staging area to git repository

-> git checkout sha1 or branch-name - changes from one commit to specific commit

-> git branch - list all local branches

-> git branch feature-test - create new branch

-> git branch -d feature-test - delete specific branch

-> git branch -m feature-test feature-new - rename specific branch

-> git checkout -b feature-test - shortcut for creating a branch with checkout

-> git commit -a -m "message" - adds and then commit


4. Merging branches

-> git merge feature-test - for example we are in master branch and if we do merge, that means we merge feature-test branch into master

-> 



1. Copy repository to our machine : git clone "url"

2. Check the status of our project (repository) : git status

3. To add to a timeline : git add .

4. To commit changes : git commit -m "comment"

5. To push our changes into cloud : git push origin master

6. To add changes into our machine : git pull origin master

7. To check branches : git branch

8. To download commits, files, and refs from a remote repository into local repo: git fetch

9. To change branch or commit : git checkout nameOfBranch

10. To fetch and download content from a remote repository and immediately update the local repository to 

match that content : git pull

11. To create branch: git checkout -b name

12. Merge another branch to current branch: git merge branch name(feature/test)

Mes: biz feature/test2-1 branc indayiq ve feature/test1 branc ini merge etmek isteyirikse.

13. git clean -fd : untracked fayllari silir

14. git reset {faylin adi}: add etdiyimiz fayli geri qaytarir

15. git stash: 

Evvelce ozumuzde olan deyiwiklikleri git add . ve git commit edirik.

Sonra kecirik main branca, pull edirik ve butun deyiwiklikleri gotururuk ozumuze. Sonra ise git merge "brancin adi" eidrik. Bu zaman hem kohne deyiwiklikler hemde oz deyiwikliklerimiz oz brancimizda olur. Ve sonda git push edirik. Bu zaman repoda butun deyiwiklikler esas brancda oturur.


-----------------------------------------------------------------------------------------------------------------------------

1. git init: folderi repository - ye cevirir

2. git status:  cari veziyyeti gosterir

3. git checkout -b feature/branch-1: branch-1 yaradir ve ora kecir

4. git log: loqlara baxmaq ucun i/o.

5. git branch: movcud branch larin siyahisini verir

6. git switch master: branch i deyiwir

7. git stash push -m "file6.txt created" : stash edir

8. git stash list: stashda olanlari gosterir

9. git stash apply 0{her hansi bir reqem}: orada saxlayir bize cekir

10. git stash pop 1{reqem}: silib bize cekil

11. git reset --soft: 

HEAD local repositorinin en son commit etdiyi mesajdir

12. git reset file1.txt: untracked fayllara qayidir

13. 



-----------------------------------------------------------------------------------------------------------------------------

1. ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f ~/.ssh/id_rsa_github_personal : ssh key generate etmek ucundur

2. tig: branch haqqinda melumat

3. git log: hansi commitler oldugunu gosterir

4. git revert [commit hash]: etdiyimiz commiti geri cekir(silir) (commiti geri cekir)

5. git checkout [commit hash]: heminki commite qayidir

6. git reset [file name]: staging areada olan file-i working directory-ye kecirdir, yeni bir nov geri alir (addi geri cekir)

7. git clean -fd: working directory-de olan fayylari silir

8. fetch - metadatani getiri; pull - hem metadatani hemde hemin branchin deyiwikliklerini getirir

9. git merge [branch name]: mes kecirib master brancha ve istediyimiz branchi mastere merge edirik

10. git rebase [branch name]: daxil etdiyimiz branchi ozumuze rebase edir

11. git stash:

12. git stash pop:

13. git restore --staged (file name) veya (.): staging areadan silir

14. git reset dd7d35a35d41603b116f730a4e28de44d2f885f4:

15. git fetch --all --prune:

1. git init: folderin icinde .git/ papkasi yaradir. Yeni local repository yaradiriq.

2. git add . veya git add *: working area-dan staging area-ya atir.

3. git commit -m "your message": staging area-dan repository-ye atir

4. 

1. git checkout -b [yourBranchName]: yeni branch yaradir ve ora kecir

2. git branch [yourBranchName]: yeni branch yaradir

3. git checkout [yourBranchName]: brancha kecid edir

4. git merge [yourBranchName]: mes biz oz branchimizda ishledikden sonra, commit edirik, sonra kecirik main brancha ve yuxaridaki kommandi icra edirik.



----------------------------------------------------------------------------------------------------------------------------

1. git checkout main^: bit addim yuxaridaki commite qalxir

2. git cherry-pick [commit-hash]: Mes biz master branchindayiq ve bu komandani etdikde, yalniz hemin deyishikliyi getirir


-----------------------------------------------------------------------------------------------------------------------------

1. vi [file name] -> faylda deyiwiklik etmek ucun

2. i -> fayla insert etmek ucun

3. esc ve :wq -> cixiw ucun

-----------------------------------------------------------------------------------------------------------------------------

1. git config --global user.name "parvin"

2. git config --global user.email "etibarliparvin@gmail.com"

3. git config -l -> to see configuration

4. git init . ->  initializing empty repository

5. git rm --cached [file name] -> add olunmuw(staging area-da olan) fayllari working area-ya qaytarir

6. git rm -r --cached . -> staging area-da olan butun fayllari working area-ya qaytarir

7. git add -A -> eger bawqa folderin icindeyikse, hem oldugumuz folderin icindeki hemde diger folderlerdeki fayllari staging area-ya atacaq

8. git commit -m "your message" -> staging areadan local repository-ye elave edir fayllari

9. git show [commit hash] -> commitde olan deyiwiklikleri gosterir

10. git diff -> ferqi gosterir

11. git log -> commit loqlarina baxmaq ucun i/o

12. git restore [file name] -> deyiwiklikleri geri qaytarir

13. git commit --amend -m "message" -> axirinci commit etdiymize deyiwiklik ede bilerik

14. git branch -r -> remote repository-de branchlarin siyahisini gosterir

15. git branch -a -> hem remote hem local branchlarin siyahisin gosterir

16. git branch [branch name] -> yeni branch yardir

17. git checkout -b [branch name] -> yeni branch yaradir ve ora kecir

18. git checkout - -> bir onceki branca kecir

19. git branch -d [branch name] -> branch silir

20. git merge [branch name] -> yazdigimiz branci oldugumuz branca merge edir

21. git log --oneline -> git log kimidir sadece daha rahat versiyada gosterir

22. git pull --rebase origin main veya git pull -r origin main -> main brancdan deyiwiklikleri bizim branca getirir

23. git rebase --continue -> git pull -r [branch name] etdikden sonra bunu etmeliyik

24. git push -f -> mecburi merge elemek ucundur

25. git revert 3528b88696c0653d599a2c85f8826cf4069b2d32 -> hemin commit-deki deyiwikliyi evvelki veziyyetine qaytarir

26. git reset file-name -> add etdiyimiz fayli unstaged hala kecirdir

27. git clean -fd -> elave etdiyimiz her weyi silir

28. 

       




Комментарии

Популярные сообщения из этого блога

Lesson1: JDK, JVM, JRE

SE_21_Lesson_11: Inheritance, Polymorphism

SE_21_Lesson_9: Initialization Blocks, Wrapper types, String class