Git pull and push []

This article is the old rules of what is listed first, I think you understand, do not waste time here, other research techniques, if. (I have only one request prohibited reproduced, send the article is to let you learn, the most annoying copy of the full network is, you can not like to eat this cake but please do not stain it)

Git push is complete wording?
Why we can directly use git push it?
Git pull is complete wording?
How do I delete a branch on github?
How to make local branch name and branch name on github not the same?
Pull and push the process of change in the branch version
Case1
Case2

Git push is complete wording?

git push origin src: dest
here origin is an alias for your remote database, this is the local branch of the src dest name represents the remote branch name

Why we can directly use git push it?

Because we use git checkout -b test origin when the test has been carried out related / specific look case1

Git pull is complete wording?

git pull origin src: dest
This place note, pull and push are from the source to the destination, but the pull is to pull the source is remote branch destination is the local branch

How do I delete a branch on github?

git push origin: develop
attention here this: there is a space in front of. That is meant to empty the local branch of a push to develop the remote branch, that is, remove the remote branch
Another is git push origin --delete develop (two of them there is a difference)

How to make local branch name and branch name on github not the same?

Develop the Push --checkout Origin git: develop2
Develop local branch develop2 is a branch of the remote
, but a different name if there is a problem, the next time you want to be pushed to look at the specific error when the develop2 case2

Here Insert Picture Description
A first project created by and uploaded to the remote repository Github so there will be a first set of configuration files, this time B then pull the code from the remote end, so that A and B have the same code.
Then B is locally modify the code, and then upload the code that is our push operation, if other people do not push the code at this time will be successful so that the remote-side code was updated to the code after revision B of
then we A also like this time we need to develop a remote-side code to pull down, this time there have been two cases:

  1. If you modify the file locally with A modified without any relationship, this time it will merge directly to the local master, so there will be no error, then A then pushed to the distal end of the code so that there will be a remote repository a B twice submitted once submitted.
  2. If the modified files with local modifications A in a relationship, this time it will error, this time we need to perform a manual merge locally, is what we call conflict resolution, then A then submit the code to the remote

Pull and push the process of change in the branch version

Here Insert Picture Description
First, there will be three branches is a master branch of a local origin / master
There is a remote master branch, the operation performed when the pull modifications in the master remote will be taken to the local dragged while the remote commitID the latest in a master submitted correspond to the local origin / master, if the direct merger, then speak directly to the remote master merge the changes directly to the modification of the local master

If the push operation, will first origin / master of commitID point on your local master branch, the equivalent of walking on the origin / master and then we then forward the local master pushed to the remote master several submission
* us how do we compare with a remote master, it is through local origin / master

case1: John Doe creates a local branch, the current branch and pushed through the distal end

git push --setupstream origin 本地分支名 (详细的看git refspec)
这个命令跟git push -u origin master 差不多尽量用上面那个
创建了一个远程的分支,但是李四在本地并没有这个分支此时如果拉取代码会发生什么?
Re:李四执行 git pull会出现以下这种情况
Here Insert Picture Description
也就是一个新的branch develop 与本地的origin/develop进行关联,现在我们来查看一下本地的分支
git branch -av
Here Insert Picture Description
发现没有本地的develop分支,所以我们就新建一个
git checkout -b develop origin/develop
这样的话我们不仅新建了一个分支我们还跟远端的origin/develop分支进行了关联,我们再看一下相关信息
Here Insert Picture Description
注意倒数第二个分支,这样我们就有了远程分支
如果采用上面这种方法我们在git checkout -b test origin/test这个地方需要给本地分支起个名字,但是太麻烦怎么办?
git checkout --track origin/test
这样就可以了他会自动创建一个跟远程分支一样的名字在本地,相当于一种简写吧

case2:如果之前从本地的develop分支提交到了远程的develop2分支,这里我们认为我们创建了关联,理论上说是这样的,所以我们第二次认为直接git push就可以了,这里有一个误区。git push 只是把当前所在的分支推送到远程所对应的分支,名字默认是相同的,但是明显现在不同,所以一定会报错。这个时候我们一定要推送到远程的develop2上我们这么做

git push origin HEAD: develop2
Why do you write? Let's talk about HEAD, HEAD points to the current branch, and the current branch point is that the latest submission, the HEAD is pointing to that commit, so now it is clear, that is the current date to a remote Submission branch of the develop2

Published 14 original articles · won praise 14 · views 291

Guess you like

Origin blog.csdn.net/weixin_43071838/article/details/104423819