I'm using Git for code versioning.
I have a development branch on which i'm doing all the dirty development.
Every time I publish a production version to the world, I want to put it under my master branch.
The problem is that whenever I merge development and master, master receive all development history.
I want to keep everything clean so the branches will look like this:
development
"init commit"
"developing"
"Version 1.0"
"bug fixing"
"bug fixing"
"Version 1.1"
master
"Version 1.0"
"Version 1.1"
Is it possible? and if so, how ?
UPDATE I tried to use Gauthier answer but it doesn't worked as I wanted.
The steps I took was as followed: 1. created an init commit in master 2. switched to development. 3. added few commits to development. 4. checkout master 5. git merge development --no-ff
The merge was successful but when i'm looking on high level at my repository, I see that in my master branch I have all the history of the development branch, while I wanted to have only init-----version 1.0.
This is screen shots of how it looks:
development branch:
master branch:
To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.
Once you merge develop to master then both are already in sync with each other so there is no need to merge again master into develop.
Do you know about --no-ff
?
You currently have:
o init commit
|
o developing
|
o Version 1.0
|
o bug fixing
|
o bug fixing
|
o Version 1.1
|
o Version 1.0
|
o Version 1.1 - development - master
(time going downwards as in your example, instead of what git log
and gitk
do)
My guess is that you are unhappy with master
because everything gets directly there, at the same level.
If you would be happy with:
o init commit
|\
| o developing
|/
o Merge branch 'development' - Version 1.0
|\
| o bug fixing
| |
| o bug fixing
|/
o Merge branch 'development' - Version 1.1 - development - master
then when you want to release what you have in development
, merge to master
with --no-ff
, and tag:
$ git checkout master
$ git merge development --no-ff
$ git tag "v1.0"
Note that you should consider working in branches named after the feature you are working on, rather than everything in development
. This would lead to better merge messages, such as "Merge branch 'killer_feature'". Maybe that's what you have in development
already, in that case, sorry.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With