# Git ile Çalışmak

## UBUNTU GIT Kurulumu

`sudo apt install git`

## Git nedir? Neden ve nasil kullaniyoruz?

{% embed url="<https://www.youtube.com/watch?v=OAvYk9-i1y0>" %}

## &#x20;Git quickstart guide - Sık kullanılan komutlar ve örnekleri

{% embed url="<https://github.com/joshnh/Git-Commands>" %}

## &#x20;Git Dersleri

**Git, GitHub ve GitLab Kullanımı**&#x20;

{% embed url="<https://www.youtube.com/watch?v=rWG70T7fePg&list=PLPrHLaayVkhnNstGIzQcxxnj6VYvsHBHy>" %}

**Sıfırdan Git Dersleri - GitHub Kullanımı**&#x20;

{% embed url="<https://www.youtube.com/playlist?list=PLHN6JcK509bOrevTCFrSMeAfBtuib4Gpg>" %}

```
git --version
git config --global user.name "Hakkı KURUMAHMUT"
git config --global user.email "hakkik@netas.com.tr"

git config --global --list

git init		// Yeni repo olusturmak

git clone http://gitlab.tgs19.com/software/tests.git


git log		//history görebiliriz.
git status	//Working area ile Stage area nın durumunu gösterir.

git add <upload edilecek dosyaları sec tümü için . koy>
git commit -m "<Yorumunu ekle>"
git push	//lokalde yaptığın tum degisiklikleri gitlab a yukle...

git branch -a		//Tüm branchları listeler

git diff remotes/main/master..origin/master
git diff --stat --color remotes/main/master..origin/master
```

`git add .` // untracked dosyaları da stage area ya atar.

`git commit .` //Sadece modified dosyaları stage area ya atar. untracked ları eklemez.

## Genel GIT Bilgisi

{% embed url="<https://docs.gitlab.com/ee/gitlab-basics/start-using-git.html>" %}

{% embed url="<http://rogerdudler.github.io/git-guide/index.tr.html>" %}

![Git Döngüsü](https://3187200845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M04QMjGnIjhYkjL9osd%2F-M04TXwxHNgQIPEAB7z8%2F-M04U1kAMCL_w7FN0A0b%2Fimage.png?alt=media\&token=6cc9a14e-e0ad-4da0-81d1-6a7e3ec3450b)

![Git Komutlarının Etkisi](https://3187200845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M04QMjGnIjhYkjL9osd%2F-M04TXwxHNgQIPEAB7z8%2F-M04U6bEygYUt0e6_vSa%2Fimage.png?alt=media\&token=4afd3f6d-a222-4574-81fa-6df14ef64b70)

![Git Komutların Daha Geniş Etkileri](https://3187200845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M04QMjGnIjhYkjL9osd%2F-M04TXwxHNgQIPEAB7z8%2F-M04UCRHrZtqAfiRKj4i%2Fimage.png?alt=media\&token=c0e22d17-315b-4bc0-a382-3a6444ef9267)

**MASTER BRANCH CEKMEK**\
&#x20;`git clone https://github.com/siemens/jailhouse.git`

**NEXT BRANCH CEKMEK**\
&#x20;`git clone https://github.com/siemens/jailhouse.git --branch=next`

**MASTER -> NEXT BRANCH a dallanmak**\
&#x20;`git clone https://github.com/siemens/jailhouse.git`\
&#x20;`git checkout -b next origin/next`

{% embed url="<https://stackoverflow.com/questions/35979642/what-is-git-tag-how-to-create-tags-how-to-checkout-git-remote-tags>" %}

`git fetch && git fetch --tags`\
&#x20;`git fetch --all --tags --prune`\
&#x20;`git tag`

## GIT ile PATCH Hazirlamak ve Yayinlamak

{% embed url="<https://stackoverflow.com/questions/6658313/generate-a-git-patch-for-a-specific-commit>" %}

{% embed url="<https://stackoverflow.com/questions/13457203/how-to-add-the-signed-off-by-field-in-the-git-patch>" %}

`git config --global --list` komutuyla kullanici bilgileri gozden gecirilir.\
`git commit . --signoff` komutuyla tum degisikler commit edilirken imzanin da eklenmesi saglanir.

Acilan yeni bencerede ilk satir PATCH Basligi olacak sekilde kisaca yazilir. Toolun kendisi \[PATCH] seklinde basliga eklentilerini kendisi yapmaktadir. Sonra patch anlatan body kismi eklenir. signoff alaninin altta kalmasina ozen gosterilir.

Degisiklikler kaydedilip cikildiginda lokal repomuza degisikler commit edilmis olunur. Artik HEAD den patch cikarabiliriz.

`git format-patch -1 HEAD` komutuyla HEAD gosterdigi yerden 1 adet patch cikarilir.

> According to the documentation link above, the -1 flag tells git how many commits should be included in the patch;
>
> `-<n>`\
> &#x20;Prepare patches from the topmost commits.

Baska bir sistemde ilgili patch uygun brancha ve commite asagidaki komutla merge edilebilir.

`git am <patch_file_name>` commit de olusturur. `git apply <patch_file_name>` sadece merge eder. commit girilmez.

### **Örnek PACH dosyasi**

```
From 3c3df6a6a8f25997e9168a9bf201661e126e6d74 Mon Sep 17 00:00:00 2001
From: HAKKI KURUMAHMUT <kurumahmut@gmail.com>
Date: Tue, 7 May 2019 10:29:26 +0300
Subject: [PATCH] Scripts: Fix for Parsing DMAR Region under Reserved
 Section  While kernel command parameters are intel_iommu=on  intremap=on at
 some machines, cat /proc/iomem shows DMAR region under  reserved section.
 This patch must be done for config creation to complete  because of
 generating DMAR region not found error although it exist. If this  patch is
 not apply, below error is throw by "config create" command whether 
 intel_iommu On or Off because "reserved" regions are currently excluded from 
 the generated config although DMAR region exists. Thus, DMAR under reserved 
 section must be parsed by parser.

Signed-off-by: HAKKI KURUMAHMUT <kurumahmut@gmail.com>
---
 pyjailhouse/sysfs_parser.py | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/pyjailhouse/sysfs_parser.py b/pyjailhouse/sysfs_parser.py
index 46c95fc2..0bbd2ba9 100644
--- a/pyjailhouse/sysfs_parser.py
+++ b/pyjailhouse/sysfs_parser.py
@@ -94,14 +94,14 @@ def input_listdir(dir, wildcards):
 
 
 def parse_iomem(pcidevices):
-    regions = IOMemRegionTree.parse_iomem_tree(
+    dmar_regions = []
+    (regions, dmar_regions) = IOMemRegionTree.parse_iomem_tree(
         IOMemRegionTree.parse_iomem_file())
 
     rom_region = MemRegion(0xc0000, 0xdffff, 'ROMs')
     add_rom_region = False
 
     ret = []
-    dmar_regions = []
     for r in regions:
         append_r = True
         # filter the list for MSI-X pages
@@ -860,21 +860,21 @@ class IOMemRegionTree:
 
         return root
 
-    # find HPET regions in tree
+    # find specific regions in tree
     @staticmethod
-    def find_hpet_regions(tree):
+    def find_regions_by_name(tree, string):
         regions = []
 
         for tree in tree.children:
             r = tree.region
             s = r.typestr
 
-            if (s.find('HPET') >= 0):
+            if (s.find(string) >= 0):
                 regions.append(r)
 
             # if the tree continues recurse further down ...
             if (len(tree.children) > 0):
-                regions.extend(IOMemRegionTree.find_hpet_regions(tree))
+                regions.extend(IOMemRegionTree.find_regions_by_name(tree, string))
 
         return regions
 
@@ -882,6 +882,7 @@ class IOMemRegionTree:
     @staticmethod
     def parse_iomem_tree(tree):
         regions = []
+        dmar_regions = []
 
         for tree in tree.children:
             r = tree.region
@@ -901,20 +902,23 @@ class IOMemRegionTree:
             ):
                 continue
 
-            # generally blacklisted, unless we find an HPET behind it
+            # generally blacklisted, with a few exceptions
             if (s.lower() == 'reserved'):
-                regions.extend(IOMemRegionTree.find_hpet_regions(tree))
+                regions.extend(IOMemRegionTree.find_regions_by_name(tree, 'HPET'))
+                dmar_regions.extend(IOMemRegionTree.find_regions_by_name(tree, 'dmar'))
                 continue
 
             # if the tree continues recurse further down ...
             if (len(tree.children) > 0):
-                regions.extend(IOMemRegionTree.parse_iomem_tree(tree))
+                (temp_regions, temp_dmar_regions) = IOMemRegionTree.parse_iomem_tree(tree)
+                regions.extend(temp_regions)
+                dmar_regions.extend(temp_dmar_regions)
                 continue
 
             # add all remaining leaves
             regions.append(r)
 
-        return regions
+        return regions, dmar_regions
 
 
 class IOMMUConfig:
-- 
2.17.1


```

{% file src="<https://3187200845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M04QMjGnIjhYkjL9osd%2F-M04TXwxHNgQIPEAB7z8%2F-M04Ua7o9sVVwMd8fz1c%2F0001-PATCH-Scripts-Fix-for-Parsing-DMAR-Region-under-Rese.patch.txt?alt=media&token=99cd78a3-4f48-4653-b0ff-2be4cbe33783>" %}
0001-PATCH-Scripts-Fix-for-Parsing-DMAR-Region-under-Rese.patch
{% endfile %}

## 2018
