16/04/2016 - GIT
Feature branch uygulamaya yeni özellikler kazandırmak, mevcut olan özellikleri kaldırmak veya hatalı çalışanları düzeltmek için kullanılılar. Bu yapılanlar daha sonradan bir sonraki release ile yayınlanırlar. Feature branch sadece develop
ile birleştirildiği için, yerel ve uzak master
branch her zaman geri kalır.
develop
branchtan türerler.develop
branch ile birleşirler.feature/xxx-xxx-xxx
kullanılır. Örnek: feature/hello-world
Feature branch ile çalışırken, diğer takım üyelerininde yapılan işi gözden geçirebilmeleri için, GitHub içinde "pull request" oluşturulur. Bu işin aslıda budur! Ayrıca aşağıdaki komutlar içinde geçen "Summary of actions" notlarına dikkat edin.
Yerel branchların eski olma olasılığı yüksek olduğu için, çalışmaya başlamadan önce bu adımların atılması mecburidir.
Aktif branch olarak develop
'u seçin.
$ git branch
* develop
master
Tüm yenilikleri alın.
$ git remote update
Fetching origin
Yerel develop
branchı yenileyin.
$ git pull origin develop
From github.com:inanzzz/manual
* branch develop -> FETCH_HEAD
Already up-to-date.
Ana olarak develop
branchtan türeyecek şekilde yaratalım.
$ git flow feature start hello-world
Switched to a new branch 'feature/hello-world'
Summary of actions:
- A new branch 'feature/hello-world' was created, based on 'develop'
- You are now on branch 'feature/hello-world'
Now, start committing on your feature. When done, use:
git flow feature finish hello-world
$ git branch
develop
master
* feature/hello-world
Yapmanız gerekeni yaptıktan sonra commit işlemi gerçekleştirin.
$ echo 'feature/hello-world' > one.txt
$ git add --all
$ git commit -m 'Feature hello-world commit'
[feature/hello-world eeaecc7] Feature hello-world commit
1 file changed, 1 insertion(+)
create mode 100644 one.txt
Bir "pull request" yaratmak için yayınlayın.
$ git flow feature publish hello-world
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 314 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:inanzzz/gitflow.git
* [new branch] feature/hello-world -> feature/hello-world
Already on 'feature/hello-world'
Your branch is up-to-date with 'origin/feature/hello-world'.
Summary of actions:
- A new remote branch 'feature/hello-world' was created
- The local branch 'feature/hello-world' was configured to track the remote branch
- You are now on branch 'feature/hello-world'
GitHub'a gittiğinizde, yayıladığınız feature branch için bir tane "pull request" açmanızı isteyen ibare göreceksiniz. Açmak işlemi sırasında, karşılaştırılacak olan branchı develop
olarak seçin ve daha sonra başlık ve açıklamayı yazarak işlemi sonlandırın.
Bu aşamada diğer takım üyeleri yapılan işi gözden geçirmek için "pull request" ile ilgilenirler. Eğer herkes yaptığınız işten memnun ise, endişelenecek bir durum olmaz. Eğer aksi bir durum söz konusu olursa, gerekli düzeltmeleri yapmak zorunda kalırsınız.
$ git branch -avv
develop c9b8a72 [origin/develop] Very first commit
* feature/hello-world 24683c1 [origin/feature/hello-world] Feature hello-world commit
master c9b8a72 [origin/master] Very first commit
remotes/origin/develop c9b8a72 Very first commit
remotes/origin/feature/hello-world 24683c1 Feature hello-world commit
remotes/origin/master c9b8a72 Very first commit
Feature branchı sonlandırın.
$ git flow feature finish hello-world
Switched to branch 'develop'
Your branch is up-to-date with 'origin/develop'.
Updating c9b8a72..24683c1
Fast-forward
one.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 one.txt
To git@github.com:inanzzz/gitflow.git
- [deleted] feature/hello-world
Deleted branch feature/hello-world (was 24683c1).
Summary of actions:
- The feature branch 'feature/hello-world' was merged into 'develop'
- Feature branch 'feature/hello-world' has been locally deleted; it has been remotely deleted from 'origin'
- You are now on branch 'develop'
Mevcut olan git durumunu kontrol et. Aşağıda da gördüğümüz gibi, yerel develop
branch uzak develop
branchtan daha ileride çünkü, feature branch yerel develop
branch ile birleştirildi. Ayrıca, yerel ve uzak feature branchlar silinmiş durumda.
$ git branch -avv
* develop 24683c1 [origin/develop: ahead 1] Feature hello-world commit
master c9b8a72 [origin/master] Very first commit
remotes/origin/develop c9b8a72 Very first commit
remotes/origin/master c9b8a72 Very first commit
Yerel develop
branchı yayınlayın.
$ git push origin develop
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 315 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:inanzzz/gitflow.git
c9b8a72..24683c1 develop -> develop
Sadece kontrol amaçlı bakarsak, yerel ve uzak develop
branchlar birbirleriyle eşit durumdalar.
$ git branch -avv
* develop 24683c1 [origin/develop] Feature hello-world commit
master c9b8a72 [origin/master] Very first commit
remotes/origin/develop 24683c1 Feature hello-world commit
remotes/origin/master c9b8a72 Very first commit
Yukarıda yapılanların kısa özetine bakalım.
# 1. Checked out into develop branch
git checkout develop
# 2. Fetched all remote updates
git remote update
# 3. Update local develop branch with remote copy
git pull origin develop
# 4. Created a feature branch that tracks develop
git flow feature start hello-world
# 5. Did some dummy work
echo 'feature/hello-world' > one.txt
git add --all
git commit -m 'Feature hello-world commit'
# 6. Publish feature branch to remote repository
git flow feature publish hello-world
# 7. Opened a "pull request" in GitHub for "peer review"
# 8. Finish feature branch
git flow feature finish hello-world
# 9. Push develop branch
git push origin develop