简体   繁体   English

如果我在提交后拉取,为什么 git push 通知数量会增加 SourceTree 中的单个提交

[英]Why git push notification number increases for a single commit in SourceTree if I took pull after commit

The MRE: MRE:

  1. Have SourceTree configurated with our codebase.使用我们的代码库配置 SourceTree。
  2. You should be at least 1 commit behind the remote repository of our CodeBase.您应该在我们 CodeBase 的远程存储库后面至少进行 1 次提交。
  3. Don't take a pull, directly commit any file.不要拉,直接提交任何文件。
  4. You will see 1 notified in the git push button in ST.您将在 ST 的 git push 按钮中看到1通知。
  5. Now, take a pull.现在,拉一下。
  6. Notice that the number changes to 2 in the git push button.请注意,git 按钮中的数字更改为2

Can someone please tell me why?有人可以告诉我为什么吗? Does that number represent no.那个数字代表否。 of commits, or something else?提交,或其他什么?

The pull has likely resulted in a merge commit, merging the local changes you had with the 1 remote change.拉取可能导致合并提交,将您拥有的本地更改与 1 个远程更改合并。

--------------L local
--------------R  remote

After pull拉后

--------------LM local
               /
--------------R  remote

You are now 2 commits (LM) ahead of the remote, your original change + the merge with remote.您现在比远程提前 2 次提交 (LM),您的原始更改 + 与远程合并。 Even though your contents are now synced with the remote.即使您的内容现在已与遥控器同步。

An alternative would be to do a pull-rebase, that will rewrite your local history to replay your changes on the remote:另一种方法是执行 pull-rebase,这将重写您的本地历史记录以在远程重播您的更改:

---------------L local
--------------R  remote

After pull-rebase:在 pull-rebase 之后:

--------------RN local
--------------R  remote

L will be rewritten to have R as a parent instead and will result in a new local commit (N). L 将被重写为将 R 作为父代,并将导致新的本地提交 (N)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM