Reference link: https: //www.liaoxuefeng.com/wiki/896043488029600/900375748016320
When you clone from a remote repository, in fact, Git automatically local warehouse master
branch and remote repository master
branch corresponds up, and the default name of the remote warehouse is origin
.
To view information about a remote repository, use git remote
:
$ git remote origin
Alternatively, with git remote -v
the display more detailed information:
$ git remote -v origin [email protected]:michaelliao/learngit.git (fetch) origin [email protected]:michaelliao/learngit.git (push)
Shown above can grab and push origin
address. If you do not push access, you can not see the push address.
Push branch
Not the local branch must take to remote push, then what needs to push branches, which do not need it?
-
master
Branches are the main branch, so to be synchronized with a remote time; -
dev
Branch is the development branch, all team members need to work on it, so it needs to be synchronized with the remote; -
branch bug fix for the bug only locally, there is no need to push the remote, unless the boss wants to see you every week in the end several bug fixes;
-
feature branch is expected to push the remote, depending on whether or not you and your little partner to develop on it.
In short, is in Git, branching can own hidden play locally, whether push, depending on your mood may be!
Push branch, that is, all the local branch of the submission pushed to the remote repository. When pushed, to specify the local branch, so that, Git will branch to the branch pushed to the remote database on the remote corresponding to:
$ Git push origin master # push the local repository of master branch $ git push origin dev # push dev branch
Multiplayer cooperative
When you clone from a remote repository, in fact, Git automatically local master
branch and a remote master
branch of the association, and the default name of the remote warehouse is origin
.
To view information about a remote repository, use git remote
:
$ git remote
origin
Alternatively, with git remote -v
the display more detailed information:
$ git remote -v
origin git@github.com:michaelliao/learngit.git (fetch)
origin git@github.com:michaelliao/learngit.git (push)
Shown above can grab and push origin
address. If you do not push access, you can not see the push address.
Push branch
Push branch, that is, all the local branch of the submission pushed to the remote repository. When pushed, to specify the local branch, so that, Git will branch to the branch pushed to the remote database on the remote corresponding to:
$ git push origin master
If you want to push other branches, for example dev
, to read:
$ git push origin dev
However, not must take the local branch to remote push, then what needs to push branches, which do not need it?
-
master
Branches are the main branch, so to be synchronized with a remote time; -
dev
Branch is the development branch, all team members need to work on it, so it needs to be synchronized with the remote; -
branch bug fix for the bug only locally, there is no need to push the remote, unless the boss wants to see you every week in the end several bug fixes;
-
feature branch is expected to push the remote, depending on whether or not you and your little partner to develop on it.
In short, is in Git, branching can own hidden play locally, whether push, depending on your mood may be!
Crawl branch
More detailed information refer to: https: //www.liaoxuefeng.com/wiki/896043488029600/900375748016320
Multiplayer mode is usually collaborative work like this:
-
First, you can try to use
git push origin <branch-name>
to push their modification; -
If the push fails, because the remote is newer than your local branch, we need to use
git pull
tried to merge; -
If the merger there is a conflict, the resolution of the conflict, and commit locally;
-
There is no conflict or post-conflict rid of, and then
git push origin <branch-name>
push will succeed!
If git pull
prompted no tracking information
, then the local branch and remote branch relationship did not create a link, use the command git branch --set-upstream-to <branch-name> origin/<branch-name>
.
This is the multiplayer mode of collaborative work, once familiar, very simple.
summary
-
View remote database information, use
git remote -v
; -
The new local branch if you do not push the remote, that is not visible to others;
-
Push from the local branch, use
git push origin branch-name
, if the push fails, first withgit pull
newly submitted grab the remote; -
Creating local and remote branch corresponding branch, using
git checkout -b branch-name origin/branch-name
the name of the best local and remote branch agreement; -
Associate local branch and a remote branch using
git branch --set-upstream branch-name origin/branch-name
; -
Grab from a remote branch, use
git pull
, if there is a conflict, we must first deal with conflict.