I was tasked to organize the repository in the way that aside other branches there would be a dedicated branch, where we would only store the commits of released version. Below is the simplified scheme of what I would like to achieve:
| trunk | | releases | |----------+-----------+----------| | commit 1 | | | | commit 2 | v0.1 ---> | tag 1 | | commit 3 | | | | commit 4 | | | | commit 5 | | | | commit 6 | v0.2 ---> | tag 2 | | commit 7 | | | | commit 8 | | | | commit 9 | | |
This is a little bit too advanced for me now, so I'd appreciate some guidance on how to do that! I'm not really sure on how would I be able to have the second tag in the "releases" branch w/o having to import all the intermediate commits. Is that possible at all?
Also, if you have a better scheme for achieving the same goal (the goal being to have a dedicated branch for releases only), please do not hesitate to advise!
That wouldn't make sense, since the tagged commits represents the state of a branch, composed of the commits and its predecessors.
Isolate just the tagged commits would write a very different history, since those commits would miss their ancestors: it is the sequence of said ancestors plus the tagged commits which leads the code base to a particular state.
The simpler approach is to make sure you tag your release commits in one dedicated branch (master for instance).
Then, a simple
git show-ref --tags can list the comimts referenced by those tags.
Or you can create a branch from any of those tags (for bug fixing a release)
git checkout -b newbranch v1.0
And you can deduce the last release tag from any commit (
git describe --long).
but the branch with releases only to store the history of special commits (the tagged ones) made into it, and point to other branches as being sources from where the commits came from
That would be possible by merging the tag commit in a "release branch", with a merge which keeps "theirs" (ie the source of the merge, meaning the source of the tagged commit)
--x--x--x--x--x--x--x (v1) (v2) ----y--------y--