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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -