Pergunta

I am working on a project & try to follow git-flow. Hence, I branch out quite often on my local machine. When I'm done, I would merge these branches into the develop branch and then delete the local branches. This happen for most bug fixes and small features. I do push important branches.

This is because I don't want to keep too many remote branch on my Github repo.

Is this an acceptable practice? I realize that by doing this, I might make it hard to find commits of a merged branch, since I no longer have a label pointing to it

Hope to hear your opinion. Thanks

Foi útil?

Solução

No, you don't push a local branch to a central repo, unless it is actually needed as branch for someone else to see (i.e. for shared work). And if you did for whatever reason, you delete the branch once it was fully merged.

Git branches serve as heads and you use them for that. After merge the history will plainly show what branch was there, so keeping it would be redundant. And if you want to continue the branch, it can simply be re-created at the last commit. IOW deleting/not pushing it loses no info whatsoever.

Outras dicas

You should read this article about git best practices

Regarding, your question: Handle obsolete branches so they can be referenced if needed, without cluttering up the git branch listing:

git merge -s ours obsolete-branch

This will merge obsolete-branch into the current branch, but completely discarding the changes in the obsolete branch. I usually make it clear in the commit message for the merge that the branch is being discarded instead of a true merge.

git merge -s ours --edit obsolete-branch

If the old changes are ever needed for reference or to be resurrected, it's as easy as checking out the last commit on the merged branch and creating a new branch pointing to it.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top