美文网首页
2021-11-18 -🎨🎨 git push 为什么必须要先

2021-11-18 -🎨🎨 git push 为什么必须要先

作者: 沐深 | 来源:发表于2021-11-18 14:05 被阅读0次

(e.g., 'git pull ...') before pushing again

Use git pull to pull the latest changes from the remote repository to your local repository. In this case, pulling changes will require a merge because you have made changes to your local repository.

I'll provide an example and a picture to explain. Let's assume your last pull from origin/branch was at Commit B. You have completed and committed some work (Commit C). At the same time, someone else has completed their work and pushed it to origin/branch (Commit D). There will need to be a merge between these two branches.

local branch:                         --- Commit C 
                                    /
                                   /
                                  /
origin/branch: Commit A ------ Commit B ---- Commit D

Because you are the one that wants to push, Git forces you to perform the merge. To do so, you must first pull the changes from origin/branch.

local branch:                         --- Commit C -- Commit E
                                    /               /           
                                   /               /             
                                  /               /               
origin/branch: Commit A ------ Commit B ---- Commit D 

After completing the merge, you will now be allowed to fast-forward origin/branch to Commit E by pushing your changes.

Git requires that you handle merges yourself, because a merge may lead to conflicts.

相关文章

网友评论

      本文标题:2021-11-18 -🎨🎨 git push 为什么必须要先

      本文链接:https://www.haomeiwen.com/subject/aiidtrtx.html