git GitHub for Windows 的“同步”有什么作用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12104513/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:26:20  来源:igfitidea点击:

What does GitHub for Windows' "sync" do?

gitgithub-for-windows

提问by Jay Bazuzi

With GitHub for Windows, you can "publish" a branch, and then "sync" that branch to GitHub.

使用 GitHub for Windows,您可以“发布”一个分支,然后将该分支“同步”到 GitHub。

enter image description here

在此处输入图片说明

Is the sync basically a git pulland git push? Or is there more to it? If I wanted to do the exact same steps as "sync" from the command line, what should I do?

同步基本上是一个git pullgit push?或者还有更多吗?如果我想从命令行执行与“同步”完全相同的步骤,我应该怎么做?

(It's not Open Source, or I'd just read that.)

(它不是开源的,或者我只是读过。)

回答by Matt Rix

Sync does git pull --rebaseand then if there are local changes, it does git push.

同步会git pull --rebase,然后如果有本地更改,它会git push

From here: http://haacked.com/archive/2012/05/21/introducing-github-for-windows.aspx#87318

从这里:http: //haacked.com/archive/2012/05/21/introducing-github-for-windows.aspx#87318

回答by Ethan Yang

Since the above answer was more than two years ago, an updated answer to this question is: due to some bugs with rebase, the "sync" button does not do git pull --rebaseanymore. Instead, it does git pullwhich will do mergeif there are conflicts, according to this release notes(see release 1.3.0).

由于上面的答案是两年多前的,所以这个问题的更新答案是:由于rebase 的一些错误,“同步”按钮git pull --rebase不再起作用。相反,根据此发行说明(请参阅 1.3.0 版),如果存在冲突,git pull它将执行合并

The link above is not available at this time. Here is the new release notes.

上面的链接目前不可用。这是新的发行说明

回答by redhotvengeance

"Sync" would be any actions necessary to have your local branch match your remote branch. If your local branch had commits that your remote branch didn't, then "sync" would push your branch. If the remote branch was ahead of your local branch, then "sync" would pull first (specifically, git pull --rebase, as was explainedby Phil Haack). "Sync" is just a shortcut to getting the local and remote to mirror each other.

“同步”是使您的本地分支与远程分支匹配所需的任何操作。如果您的本地分支有远程分支没有的提交,那么“同步”将推送您的分支。如果远程分支在您的本地分支之前,那么“同步”将首先拉取(具体来说git pull --rebase,正如Phil Haack所解释的那样)。“同步”只是让本地和远程相互镜像的捷径。

From the GitHub site:

GitHub 站点

The sync button turns the complex workflow of pulling and pushing into a single operation. It notifies you when there are new changes to pull down and lets you quickly share local changes.

The sync button turns the complex workflow of pulling and pushing into a single operation. It notifies you when there are new changes to pull down and lets you quickly share local changes.

回答by Ashwin Sinha

To add to @ethanyang's answer,

要添加到@ethanyang 的回答中

According to the alias configured in the gitconfig,

根据gitconfig中配置的别名,

[alias]
...
sync = !git pull && git push