Why commit first, then pull, then push? Instead of committing and then push directly?

  git, question

I really don’t understand, there is no clear statement about this on the internet.
The situation is as follows: there is now a warehouse in the remote, and one branch is master. Then my local warehouse came down from clone on the remote master. Everyone is clone down, then in their own local change, then commit and then pull and push, everyone is doing so. So now the question is:

1, then I am a local branch? Or is it just a local warehouse?

2. If I create a new branch at a remote location and then pull it down, is there a branch here? Is my local branch the remote newly-built branch?

3. What is the difference between a local warehouse and a local branch?

4. Is commit submitted to the local warehouse and then push, does this push push all the code to the remote warehouse or just push the commit place to the remote warehouse?

5, then why commit first, then pull, then push, I pull, not to change their own code to cover it, because there is no remote code I changed, I pull, not to cover my local changes good place? Then how can I push?

6, the two branches, a and b, a merging b and b merging a, is there any difference?

  1. The relationship between local and remote is equivalent to two branches. You feel the same because of you.git pullAt the same time, it has automatically bound the corresponding relation, set-upstream..balbala

  2. The reason why you created a new branch remotely and pulled it to the local is the same. It belongs to a copy, but the local branch and the remote branch are already two things.

  3. Local branches belong to local warehouses and are inclusive relationships. A warehouse can have many branches. If it is tag, independent warehouses can be separated.

  4. Certainly, it will not be pushed to the remote place in full quantity. It is by comparing the records of commit. If the local place is higher than the remote place, it will directly push out the extra records.commitIf you go up there, these local onescommitAnd remotecommitThe conflicting part ismerge, and then according to the submission time sort to create a new merge commit record again

  5. This situation of commit, pull and push is to deal with the situation of multi-person development.

    1. commitIt is to tell git what I have changed in this submission. Otherwise, you just changed it, but git does not know what you have changed, so it is impossible to judge and compare.

    2. pullFor the comparison record of local commit and remote commit, git compares the operations according to the number of lines in a file. If the same line of a file is operated at the same time, there will be conflicts. git will also mark the conflicts. At this time, it is necessary to first pull the person who conflicts with you to ask whose code to keep, and then ingit add && git commit && git pullThese three companies, pull once again, are to prevent another person from submitting another version of something when you negotiate again. if the process is repeated, it will usually be merged directly to you when there is no conflict, and your code will not be overwritten.

    3. There are cases of code coverage or loss: for example, the versions of both A and B’s code pull are 1,A submitted 2,3 locally and pushed to the remote, and B did not modify itcommitOperation, he first wrote something himself, and thengit pullBy this time, the local version of B has reached 3, and B changed the code written by A in the local version of 3 before proceeding.git commit && git pushSo in the remote version it is 4, and A’s code is overwritten, so everyone has to commit before pulling, otherwise it pull really overwrite the code.

  6. The only difference between the two merging is that when A->B occurs, branch b will generate a merge_commit message. at this time, b is in the merged state and a is not merged. if nowNo changes have taken place.Execute B->A to switch directly, even merge_commit will not be generated

This isMy blogThere are some steps that I usually put wrong in git