Git push common usage

Git push

        In the modification using the git commit command from the staging area to submit to the local repository after, only the last step in the local repository branch pushed to the corresponding branch on the remote server , and if the constitution is not clear repository, you can see me another paper, the basic structure of git repository.

    The general form of git push git push <remote host name> <local branch name> <remote branch name> , e.g.

 git push origin master: refs / for / master, i.e. is pushed to the master branch corresponding to the master branch on the remote host origin, origin is the name of the remote host,

    The first master is the local branch name, the second master is the remote branch name.

    1.1 git push origin master

        If the remote branch is omitted, as it indicates that the local branch push remote branch (generally both the same name) thereto trace relationship exists, if the remote branch does not exist, it will be newly created

     1.2 git push origin:refs/for/master 

  If you omit the local branch name, then delete the specified remote branch, because this is equivalent to pushing an empty local branches to remote branches, equivalent to git push origin --delete master

    1.3 git push origin

   If the current branch and a remote branch trace relationship exists, then the local branch and a remote branch can be omitted, the push current branch corresponds to the branch origin host 

 1.4 git push

  If the current branch is only a remote branch, then the host name can be omitted, shaped like a git push, you can use git branch -r, view the remote branch name

 1.5 git push other orders

  Several common usage is sufficient to meet our daily development, there are several extensions of usage, as follows:

    (1) git push -u origin master currently exists a plurality of hosts and a branch trace relationships, the -u parameter to specify a default host, so the following parameters can be used without any git push,

      git push without any parameters, the default push only the current branch, this is called simple way, there is a matching way, will have to push all of the local branch of the corresponding remote branch, using matching default before Git 2.0, now changed to simple mode

      If you want to change the settings, you can use the git config command. git config --global push.default matching OR git config --global push.default simple; git config -l can be used to check the configuration

    (2) git push --all origin when this is the case regardless of whether or not there is a corresponding remote branch, the local branches of all pushed to the remote host, then need -all options

    (3) git push --force origin git push when the need to update the local first git pull consistent with the server version, if lower than the local repository on a remote server, then the general will prompt you git pull updates, if we must submit, you can use this command.

    (4) git push origin --tags // git push, when not to push branches, if we must push tag, then you can use this command

 About 1.6 refs / for

  // refs for significance is that / we submit the code to the server after code review is needed in order to carry out after the merge, and refs / heads do not need

 

Published 136 original articles · won praise 71 · views 160 000 +

Guess you like

Origin blog.csdn.net/u012308586/article/details/104679493