Reputation: 123
When working with git on my local machine I usually commit a lot. For this I use topic branches. Then I merge such a topic branch into a branch called develop which will be pushed to a remote repo.
I always merge with --no-ff so their is always a commit for my whole topic.
Now I'd like to only push this commit with a specified description what I did on the whole in this branch.
I would prefer this because you can look at the commit history on the server and see directly what happened and don't need to read every single commit.
And for my local work I would have the full history if I want to reset my branch or something similar.
I don't know if their is a way to do this in git but it would be very useful for me so I give it a try to ask you.
Upvotes: 4
Views: 2801
Reputation: 1323753
From what you are describing, it looks like all you need to do is to push only your devel branch, and not push your topic branches.
devel
branch will contain that one commit (created on the merge with topic branch) which summarize what has been done.git merge --squash
would be useful to produced that single commit.topic
branches remain unpublished (not pushed) and contain the all detailed history.As Daniel Yankowsky mentions in the comment, a git merge --squash
works, but "lost the change lineage".
The is why you could setup 2 'devel' branches.
t--t--t--t (topic)
/
x--x (devel)
\
p--p (devel_pub)
devel
' branch)devel_pub
'), where you perform a merge --squash
)(topic) | x--x--t--t--t--t--d (devel) \ p--p--T (devel_pub, with T being "git merge --squash topic")
Upvotes: 1
Reputation: 37441
It sounds like you may want to use git rebase
to rewrite your local history before pushing.
Why don't you want it on the remote side, anyway? It doesn't seem like it would matter very much. Just set the remote end to show only one branch that has your merge commits.
Upvotes: 0
Reputation: 7006
I don't know of any way to do what you are describing, and I suspect that it is working against git's design. It sounds like you want to summarize a whole set of commits. What if you merge with the --no-commit option, and edit the merge commit message to summarize your branch's changes?
Upvotes: 1