/bin/bash
cd /Users/cemt/projects/cop/git-tag
alias ll="ls -al --color"
rm -rf myrepo master_1
git config --global init.defaultBranch master
# 1. Adım: repo hazırlığı
git init myrepo
cd myrepo
# master_1 dosyası
echo "master v1" > master_1
git add master_1
git commit -m "Initial commit"
# Etiket
git tag 1.0.0
# 2. Adım: feature/1 dalı ve 3 commit
git checkout -b feature/1
echo "f1.1" > feature_1_1
git add .
git commit -m "feature/1 step 1"
echo "f1.2" > feature_1_2
git add .
git commit -m "feature/1 step 2"
echo "f1.3" > feature_1_3
git add .
git commit -m "feature/1 step 3"
# 3. Adım: 1.1.0 etiketi ve master’a birleşme (branch silinmeyecek)
git tag 1.1.0
git checkout master
git merge --no-ff feature/1 -m "Merge feature/1 into master"
# 4. Adım: feature/2 dalı ve 2 commit
git checkout -b feature/2
echo "f2.1" > feature_2_1
git add .
git commit -m "feature/2 step 1"
echo "f2.2" > feature_2_2
git add .
git commit -m "feature/2 step 2"
# 1.2.0 etiketi şimdilik feature/2 üzerinde olacak:
git tag 1.2.0
# 5. Adım: başka geliştirici bugfix/1 dalı açıyor
git checkout master
git checkout -b bugfix/1
echo "bug1" > bugfix_1_1
git add .
git commit -m "bugfix/1 step 1"
echo "bug2" > bugfix_1_2
git add .
git commit -m "bugfix/1 step 2"
git tag 1.1.1feature/2 -> master & bugfix/1 -> master
# 6. Adım: feature/2 → master birleşmesi
git checkout master
git merge --no-ff feature/2 -m "Merge feature/2 into master"
# 7. Adım: bugfix/1 → master birleşmesi
git merge --no-ff bugfix/1 -m "Merge bugfix/1 into master"Uzun ömürlü product/2 ve 3 dalları ve etiketleri başlıyor
# 8. Adım: product/2 dalı açılış ve 2.0.0 etiketi
git checkout master
git checkout -b product/2
git tag 2.0.0
# 9. Adım: 3 commit ve 2.0.1 etiketi
echo "p2.1" > product2_1
git add .
git commit -m "product/2 step 1"
echo "p2.2" > product2_2
git add .
git commit -m "product/2 step 2"
echo "p2.3" > product2_3
git add .
git commit -m "product/2 step 3"
git tag 2.0.1
# 10. Adım: 2 commit ve 2.0.2 etiketi
echo "p2.4" > product2_4
git add .
git commit -m "product/2 step 4"
echo "p2.5" > product2_5
git add .
git commit -m "product/2 step 5"
git tag 2.0.2
# 11. Adım: product/3 dalı açılış ve 3.0.0 etiketi
git checkout master
git checkout -b product/3
git tag 3.0.0
# 12. Adım: 3 commit ve 3.0.1 etiketi
echo "p3.1" > product3_1
git add .
git commit -m "product/3 step 1"
echo "p3.2" > product3_2
git add .
git commit -m "product/3 step 2"
echo "p3.3" > product3_3
git add .
git commit -m "product/3 step 3"
git tag 3.0.1
# 13. Adım: 2 commit ve 3.0.2 etiketi
echo "p3.4" > product3_4
git add .
git commit -m "product/3 step 4"
echo "p3.5" > product3_5
git add .
git commit -m "product/3 step 5"
git tag 3.0.2
master -> bugfix/2
# 1. Adım: bugfix/2 dalını aç
git checkout master
git checkout -b bugfix/2
# 2. Adım: 3 commit yap
echo "fix a" > bugfix2_1
git add .
git commit -m "bugfix/2 step 1"
echo "fix b" > bugfix2_2
git add .
git commit -m "bugfix/2 step 2"
echo "fix c" > bugfix2_3
git add .
git commit -m "bugfix/2 step 3"
git tag 1.1.2
Etiketleri listele ve öncül, ardıl ilişkisiyle sırasını bul:
# Sonuç
git describe --tags 1.2.0
# veya
git tag --sort=creatordate
# veya
git describe --tags --abbrev=0 1.1.2^bash-3.2$ git log --graph --oneline --all
* 3f3d7a4 (HEAD -> bugfix/2, tag: 1.1.2) bugfix/2 step 3
* f8edd75 bugfix/2 step 2
* ba97143 bugfix/2 step 1
| * cfd7c0e (tag: 2.0.2, product/2) product/2 step 5
| * 26075fd product/2 step 4
| * 9e13023 (tag: 2.0.1) product/2 step 3
| * e74aedc product/2 step 2
| * 91c54b5 product/2 step 1
|/
| * bca2763 (tag: 3.0.2, product/3) product/3 step 5
| * 0303afd product/3 step 4
| * 1861fb6 (tag: 3.0.1) product/3 step 3
| * f33afb3 product/3 step 2
| * e0d01ad product/3 step 1
|/
* 014a31d (tag: 3.0.0, tag: 2.0.0, master) Merge bugfix/1 into master
|\
| * 07d9e0a (tag: 1.1.1, bugfix/1) bugfix/1 step 2
| * 8f8af56 bugfix/1 step 1
* | f7b2a68 Merge feature/2 into master
|\ \
| |/
|/|
| * 5cc1e1f (tag: 1.2.0, feature/2) feature/2 step 2
| * 80002bd feature/2 step 1
|/
* 185a95b Merge feature/1 into master
|\
| * b28c1a8 (tag: 1.1.0, feature/1) feature/1 step 3
| * e3bd5ce feature/1 step 2
| * 4818612 feature/1 step 1
|/
* c621a11 (tag: 1.0.0) Initial commit
bash-3.2$ git describe --tags --abbrev=0 1.1.2^
2.0.0
bash-3.2$ git describe --tags --abbrev=0 2.0.2^
2.0.1
bash-3.2$ git describe --tags --abbrev=0 2.0.1^
2.0.0
bash-3.2$ git describe --tags --abbrev=0 2.0.0^
1.1.0
bash-3.2$ git describe --tags --abbrev=0 1.1.1^
1.1.0
bash-3.2$ git describe --tags --abbrev=0 1.1.0^
1.0.0
bash-3.2$ git describe --tags --abbrev=0 1.2.0^
1.1.0
bash-3.2$ git describe --tags --abbrev=0 1.1.1^
1.1.0bash-3.2$ git log --simplify-by-decoration --graph --oneline --all
* 3f3d7a4 (HEAD -> bugfix/2, tag: 1.1.2) bugfix/2 step 3
| * cfd7c0e (tag: 2.0.2, product/2) product/2 step 5
| * 9e13023 (tag: 2.0.1) product/2 step 3
|/
| * bca2763 (tag: 3.0.2, product/3) product/3 step 5
| * 1861fb6 (tag: 3.0.1) product/3 step 3
|/
* 014a31d (tag: 3.0.0, tag: 2.0.0, master) Merge bugfix/1 into master
|\
| * 07d9e0a (tag: 1.1.1, bugfix/1) bugfix/1 step 2
* | 5cc1e1f (tag: 1.2.0, feature/2) feature/2 step 2
|/
* b28c1a8 (tag: 1.1.0, feature/1) feature/1 step 3
* c621a11 (tag: 1.0.0) Initial commit