如何将 GitHub for Mac 与本地 Git 存储库一起使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10197161/
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 13:29:47  来源:igfitidea点击:

How to use GitHub for Mac with local Git repo

gitgithub-for-mac

提问by K. Carpenter

I'm trying to use a local Git repository (i.e. not hosted on GitHub at all), and I'm having troubles with GitHub for Mac.

我正在尝试使用本地 Git 存储库(即根本不托管在 GitHub 上),但我在使用 GitHub for Mac 时遇到了问题。

It shows my outgoing changes, but then I appear to have to Push to the server, and there appears to be no way to perform a "Sync" without publishing to GitHub (which we don't want to do).

它显示了我的传出更改,但随后我似乎必须推送到服务器,并且似乎无法在不发布到 GitHub 的情况下执行“同步”(我们不想这样做)。

I haven't found any documentation regarding this, or users experiencing similar issues.

我没有找到任何关于此的文档,也没有找到遇到类似问题的用户。

Any suggestions?

有什么建议?

回答by learnvst

The application is a free tool to encourage you to use GitHub, and works best with GitHub, but it can also work with private repositories now as detailed in this excerpt from http://mac.github.com/help

该应用程序是鼓励您使用 GitHub 的免费工具,最适合与 GitHub 一起使用,但它现在也可以与私有存储库一起使用,如http://mac.github.com/help 的摘录中所述

Multiple Git remotes & non-GitHub remotesGitHub for Mac does not support multiple Git remotes. We will only work with the origin remote. If you wish to push & pull to other remotes, we suggest that you use the command line client.

GitHub for Mac is optimized to work with GitHub remotes — but if you wish to use a non-GitHub remote, it will work just fine. Set the remote manually in the settings tab and everything else should work as expected.

多个 Git 远程和非 GitHub 远程GitHub for Mac 不支持多个 Git 远程。我们将只使用 origin 遥控器。如果您希望推拉到其他遥控器,我们建议您使用命令行客户端。

Mac 版 GitHub 已针对 GitHub 遥控器进行了优化——但如果您希望使用非 GitHub 遥控器,它也能正常工作。在设置选项卡中手动设置遥控器,其他一切都应该按预期工作。

I have tested the latest [Version 1.2.6 (010d408)] software with some of my private non-github remotes and it seems to work ok with some fiddling. In theory, you should just be able to drag and drop an existing repository into the new repository pane. If the existing repository on your local machine has been set up to work with your remote from the command line, then it should work just fine in the GitHub software....

我已经用我的一些私人非 github 遥控器测试了最新的 [Version 1.2.6 (010d408)] 软件,它似乎可以通过一些摆弄来正常工作。理论上,您应该能够将现有存储库拖放到新存储库窗格中。如果您本地机器上的现有存储库已设置为从命令行与您的遥控器一起使用,那么它应该可以在 GitHub 软件中正常工作....

However, I ran into a few hiccups along the way. For example, the GitHub for Mac software refused to acknowledge one of my repositories. I would continuously drag and drop it into the Mac software and it would refuse to show up in the repository list. Sometimes, a random repository would pop up instead from my GitHub account! Some of my other private repos worked just fine, and I could circumnavigate the strange bug by manually moving the .git directory to another folder and then dragging the local repo into the Mac software pane. It would then offer to set up a new repo in that folder. After this was done, I replaced the new .git directory with my old backup. Even with this little problem fixed, I still occasionally get random errors dialogue boxes that inform me that there has been a "Git Error" when browsing commits, although this information appears to be just an annoyance, as all my commit information is displayed correctly. I normally work from the command line and am pretty sure that there was no problem with the setup of my git repo.

然而,我一路上遇到了一些小问题。例如,GitHub for Mac 软件拒绝承认我的存储库之一。我会不断地将它拖放到 Mac 软件中,它会拒绝显示在存储库列表中。有时,会从我的 GitHub 帐户中弹出一个随机存储库!我的其他一些私人存储库工作得很好,我可以通过手动将 .git 目录移动到另一个文件夹,然后将本地存储库拖到 Mac 软件窗格中来绕过这个奇怪的错误。然后它会提供在该文件夹中设置一个新的存储库。完成后,我用旧备份替换了新的 .git 目录。即使解决了这个小问题,我仍然偶尔会收到随机错误对话框,通知我浏览提交时出现“Git 错误”,尽管此信息似乎只是一个烦恼,因为我所有的提交信息都正确显示。我通常从命令行工作,并且非常确定我的 git repo 的设置没有问题。

In summary, GitHub form Mac is awesome for Gitub based repos, but still not perfect for your own repos on different remotes. There are, however, other free tools such as gity and gitx that work on mac and allow you to use a repo hosted anywhere. I have not tried Tower, but it looks pretty awesome.

总而言之,GitHub 形式的 Mac 非常适合基于 Gitub 的存储库,但对于您自己在不同遥控器上的存储库仍然不完美。但是,还有其他免费工具(例如 gity 和 gitx)可在 mac 上运行,并允许您使用托管在任何地方的存储库。我没有尝试过Tower,但它看起来非常棒。

回答by ngm

I don't actually have a Mac to try this, so maybe I'm missing something glaringly obvious, but according to http://mac.github.com/help:

我实际上没有 Mac 来尝试这个,所以也许我错过了一些明显的东西,但根据http://mac.github.com/help

GitHub for Mac is optimized to work with GitHub remotes — but if you wish to use a non-GitHub remote, it will work just fine. Set the remote manually in the settings tab and everything else should work as expected.

Mac 版 GitHub 已针对 GitHub 遥控器进行了优化——但如果您希望使用非 GitHub 遥控器,它也能正常工作。在设置选项卡中手动设置遥控器,其他一切都应按预期工作

so I presume in the settings you can do something similar to doing the following on the command-line:

所以我认为在设置中您可以执行类似于在命令行上执行以下操作的操作:

git remote add origin some/shared/place/within/your/network

Then when you hit the Sync button it should use that it seems. I would guess that behind the scenes the Github client is simply using your project's .git/configfile, so I'd be surprised if you can't edit your remote as you see fit.

然后当你点击同步按钮时,它应该使用它看起来的样子。我猜想在幕后,Github 客户端只是在使用您的项目.git/config文件,所以如果您不能按照您认为合适的方式编辑您的遥控器,我会感到惊讶。

See e.g. this postfor a few different ways of setting up your shared remote.

有关设置共享遥控器的几种不同方法,请参见例如这篇文章

回答by pjs

Clone your repository in the command-line, then add it to GitHub.app as a local repository. That seems to work for me -- it looks like GitHub.app is successfully reading the origin from the .git/configfile and using it to sync.

在命令行中克隆您的存储库,然后将其作为本地存储库添加到 GitHub.app。这似乎对我有用——看起来 GitHub.app 成功地从.git/config文件中读取源并使用它进行同步。

回答by jimw

If you don't want to publish your code on github but do want to use the github tools, you could pay for private repositories:

如果你不想在 github 上发布你的代码,但想使用 github 工具,你可以支付私有存储库的费用:

https://github.com/plans

https://github.com/plans

then you can use the github tools and still keep your code to yourself. Otherwise, you'll have to use something other than the github mac application to handle your git workflow:

然后你可以使用 github 工具,并且仍然保留你自己的代码。否则,您将不得不使用 github mac 应用程序以外的其他东西来处理您的 git 工作流程: