git - How to keep local topic (feature) branches from being pushed to the remote -


suppose pull branch develop remote repo , create local branch feature_xxx work on feature

a---b---c---d    develop      \       x          feature_xxx 

i make commits feature_xxx branch , merge local develop branch.

a---b---c---d---e  develop      \         /       x---y---z    feature_xxx 

finally push develop branch remote repo

git push my_remote develop 

the problem commits pushed remote, including x, y, z commits, branches on remote this:

a---b---c---d---e  develop      \         /       x---y---z 

actually used x, y, z commits during development , not want them show on remote. i'd branch on remote this:

a---b---c---d---e  develop 

i suppose there several ways achieve in git, solution simplest?

the simpler short-hand rebase operation others outlining, if want one commit represent work branch, use --squash option git merge:

git checkout develop git merge --squash feature_xxx 

this leaves with

a---b---c---d---xyz  develop  \            x---y---z    feature_xxx 

where xyz single commit. can delete feature_xxx branch.

as aside - matter of terminology, worth keeping straight in opinion: original approach, not pushing feature_xxx branch. in git branch not line of commits; branch ref, pointer tip commit , nothing more.

so question, in git terms, not how avoid pushing branch. how represent changes branch if changes had been made in single, normal commit directly on develop.

while it's matter of opinion , circumstance, prefer keep topology of feature branches myself. when ask people why think --squashed merge "cleaner", ends being log output. if put commit message on merge, can linear log output passing --first-parent log command, without need use revisionist history --squash merges.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -