37

私はGITを使ったバージョン管理は初めてです。私はこのガイドを読み、ここの図に示されている基本的なアプローチに従っています。それでも、新しい機能の開発を既存のコードから分離するために git ブランチを使用する方法については、いくつか疑問があります。

ここに例があります。最初に、私のリポジトリに次の 2 つの主要なブランチが含まれているとします。

  • マスター ブランチ (リリース バージョンを含む)
  • ブランチの開発 (既存のプロジェクト機能から分離するための新しい修正または機能を含む)

新しい機能やモジュールを開発する必要があるときは、Develop からブランチを作成し、そこで新しいコード プロジェクトを開始します。たとえば、SunStar、および に関連する機能を追加するために 3 つの新しいブランチを作成しますSuperNova。現在、私のリポジトリには 5 つのブランチが含まれています。

  • Master branch: Release 1.0.0
  • Develop branch: Modification after release 1.0.0
  • NewModule_Sun branch: add Sun to project (create from Develop branch)
  • NewModule_Star branch: add Star to project (create from Develop branch)
  • NewModule_SuperNova branch: add SuperNova to Project (create from Develop branch)

For Release 1.0.1, I want to include the the Sun and Star modules, but not SuperNova. So, I merge them with Develop and then merge Develop with the Release:

  1. Merge NewModule_Sun into Develop
  2. Merge NewModule_Star into Develop
  3. Merge Develop into Master (release 1.0.1)

The Develop branch needs to be kept permanently, but the Sun and Star branches are no longer needed. They get deleted:

  1. Delete the NewModule_Sun branch
  2. Delete the NewModule_Star branch

After these changes my repository contains the following three branches:

  • Master Branch: Release 1.0.1
  • Develop Branch: Modification after release 1.0.1
  • NewModule_SuperNova branch: Modification after release 1.0.0 (created from Develop when it was not merged with the Star/Sun branches)

==

Firstly, am I using git branches correctly?

Secondly, I reviewed the history of the final Develop branch, and it seems that I have lost some information on the NewModules. Is that normal? And, is it possible to transfer all the history information to the Develop branch?

Thank you!!

4

2 に答える 2

23

私はgitを適切に使用していますか?

はい、あなたが説明するワークフローは、ほとんど標準的なワークフローです。いくつかのブランチを作成して作業し、完了したらそれをマージして不要なブランチを削除します (そのブランチで開発を続ける場合を除きます)。

ブランチを削除した後、履歴を表示すると、ブランチ自体に関するすべての情報が失われているように思えます...それは正常ですか?

はい、これは正常です。

ブランチを削除することはできますが、履歴情報はそのままにしておきますか?

ここで何を意味するのかわかりません。削除する前にブランチをマージしている限り、履歴は残っています。それを別のブランチにマージしただけで、そのブランチで履歴を確認できます。それがあなたが求めているものである場合、ブランチがいつ削除されたかを知る方法はありません。

于 2012-04-04T14:49:18.487 に答える
12

git ブランチの適切なパターンを定義しているhttp://nvie.com/posts/a-successful-git-branching-model/を読むことをお勧めします。

私は開発ブランチを一定期間保持し、それらのリビジョンで行った変更履歴を保持する価値がなくなるまで (約 6 か月) 保持し、その後削除することを発見しました。

于 2012-04-04T10:22:09.310 に答える