git - What is the difference between push branch and merge to master then push? -
one way:
git checkout mybranch git push origin mybranch:master
another way:
git checkout master git merge mybranch git push
what difference between these two?
this:
git checkout mybranch git push origin mybranch:master
just attempts fast-forward (i.e. non-forced update) push of mybranch
master
. if master
reachable mybranch
, i.e. master
doesn't contain commits mybranch
doesn't have, push succeed; otherwise, push rejected.
the preceding git checkout mybranch
irrelevant git push
, since you're using refspec mybranch:master
. can learn more refspecs @ git internals - refspec.
this:
git checkout master git merge mybranch git push
actually merges mybranch
master
, , attempts push remote (with default configuration of git repo, remote origin).
because mybranch
merged master
, assuming remote master
behind local one, i.e. doesn't contain commits local 1 doesn't have, push succeed, otherwise fail.
Comments
Post a Comment