29/11/2021

Git -1

Evde ki eski laptopa bir VM içine debian kurdum ve onun içinde docker ile bir git server kurdum.

https://registry.hub.docker.com/r/gitea/gitea/tags

daha sonra ilgili dokümantasyona bakarak kurulumu tamamladım. Docker-compose.yml dosyası aşağıda ki gibi.

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:1.15.6
    container_name: gitea
    environment:
      - USER_UID=1001
      - USER_GID=1001
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=gitea
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /home/can/.ssh/:/home/can/gitea/gitea/ssh
    ports:
      - "3000:3000"
      - "2222:22"
    depends_on:
      - db

  db:
     image: postgres:13
     restart: always
     environment:
       - POSTGRES_USER=gitea
       - POSTGRES_PASSWORD=gitea
       - POSTGRES_DB=gitea
     networks:
       - gitea
     volumes:
       - ./postgres:/var/lib/postgresql/data

Bu arada authorized keys dosyasında komut giriliyormuş onu öğrendim kenera not ettim inceleyeceğim.

Daha sonra remote origin olarak ekledi

ssh://git@localhost:2222/Can/Test1.git

ayrıca web arayüzünden (http://192.168.0.190:3000) ssh keyimi de ekledim.

windows laptopuma git kurdum.

ve git mingw64 ile ilk repo mu init ettim.

ssh 192.168.0.190 -p 2222 "init first_repo.git"

Powershell path variable ıma da mingw path ini ekledim.

C:\Program Files\Git\mingw64\bin

neyse artık klasörümüze gidebiliriz.

ARANOT

gitea password recovery

docker exec -it <container ID> su git bash -c "gitea admin user change-password -u <username> -p <password>"
docker exec -it gitea su git bash -c "gitea admin user change-password -u can -p root"

Önce biraz git mantığı

https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse1.mm.bing.net%2Fth%3Fid%3DOIP.gPBljo_uRh-IBtHY2oB7igHaE5%26pid%3DApi&f=1

Working Copz git add ile eklediğimiz staging area oluyor.

git init ile de local repo kuruluyor.

burada git init dedikten sonra .git adında gizli bir klasör oluşuyor içine girip baktığımızda

PS C:\Users\can\git\first_repo\.git> dir


    Directory: C:\Users\can\git\first_repo\.git


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        29.11.2021     13:55                hooks
d-----        29.11.2021     13:55                info
d-----        29.11.2021     13:55                objects
d-----        29.11.2021     13:55                refs
-a----        29.11.2021     14:00            112 config
-a----        29.11.2021     13:55             73 description
-a----        29.11.2021     13:55             23 HEAD

şimdi first_repo kalsörü altında iki adet dosya mevcut test.txt ve test2.txt

birini git add ile staging area ya alıyorum.

PS C:\Users\can\git\first_repo> git add .\test.txt
warning: LF will be replaced by CRLF in test.txt.
The file will have its original line endings in your working directory

şimdi git status ile duruma bakalım.

PS C:\Users\can\git\first_repo> git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   test.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        test2.txt

git add ile eklediğimiz yada eklenmiş olan bir dosyayı yine “git rm –cached <dosya>” ile geri çıkarabiliriz.

tüm klasörü eklemek için “git add .

şimdi ilk commitimizi yapalım

PS C:\Users\can\git\first_repo> git commit -m "ilk commit"
[master (root-commit) e5c0fdc] ilk commit
 1 file changed, 32 insertions(+)
 create mode 100644 test.txt

log larada bakalım

PS C:\Users\can\git\first_repo> git commit -m "ilk commit"
[master (root-commit) e5c0fdc] ilk commit
 1 file changed, 32 insertions(+)
 create mode 100644 test.txt
PS C:\Users\can\git\first_repo> git log
commit e5c0fdc810edd8d628f79946bd9ed8625401cd47 (HEAD -> master)
Author: can <canbuyukburc@hotmail.com>
Date:   Mon Nov 29 15:03:30 2021 +0100

Bir dosyada değişiklik yaptım ve status ile baktım ki statging dışında kalmış.

PS C:\Users\can\git\first_repo> wsl vim test.txt
PS C:\Users\can\git\first_repo> git status
On branch master
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:   test.txt

no changes added to commit (use "git add" and/or "git commit -a")

tekrar eklemek gerekiyor.

yada commit -a ile

PS C:\Users\can\git\first_repo> git commit -m "ucuncu commit" -a
warning: LF will be replaced by CRLF in test.txt.
The file will have its original line endings in your working directory
[master 00028c5] ucuncu commit
 1 file changed, 1 insertion(+)

ve loglara baktığımızda her commitin unique IDsi olduğunu görürüz ve bunlar ile eski versiyonlara dönmek mümkün olmaktadır.

PS C:\Users\can\git\first_repo> git log
commit 00028c5d64059245b4c1495755be2c1912718e10 (HEAD -> master)
Author: can <canbuyukburc@hotmail.com>
Date:   Mon Nov 29 15:30:43 2021 +0100

    ucuncu commit

commit b2b71254800b01606c2857263fba45312b525e7b
Author: can <canbuyukburc@hotmail.com>
Date:   Mon Nov 29 15:25:50 2021 +0100

    commit 2

commit e5c0fdc810edd8d628f79946bd9ed8625401cd47
Author: can <canbuyukburc@hotmail.com>
Date:   Mon Nov 29 15:03:30 2021 +0100

    ilk commit

Leave a Reply