简体   繁体   English

如何在Windows计算机上设置私有GIT存储库,并使用SourceTree和Bitvise SSH Server从Mac访问它?

[英]How do I set up a private GIT repository on a Windows machine and access it from a Mac using SourceTree and Bitvise SSH Server?

I have a private Windows-10 PC on my local network and I want to use it to house a GIT repository to be accessed from my Mac via SSH, using SourceTree and Bitvise SSH Server. 我在本地网络上有一台专用的Windows-10 PC,我想使用它来存放一个GIT存储库,以便使用SourceTree和Bitvise SSH服务器通过SSH从Mac上访问它。 How to do that? 怎么做?

Sharing my solution, as it cost some effort and there were some non-obvious steps. 分享我的解决方案,因为这需要花费一些精力,并且有一些不明显的步骤。 In the outline below, my Windows PC is named ineke and I use an account named bill on the Mac and a local account named bill on Windows. 在下面的概述中,我的Windows PC名为ineke ,在Mac上使用的帐户名为bill ,在Windows上使用本地的帐户bill The two names don't have to be the same of course. 当然,这两个名称不必相同。

Using Windows-10 Creators Update, MacOS Sierra 10.12.5, Git 2.6.2 (free), SourceTree 2.5.3 (free) and BitVise SSH Server 7.32 (free). 使用Windows-10 Creators Update,MacOS Sierra 10.12.5,Git 2.6.2(免费),SourceTree 2.5.3(免费)和BitVise SSH Server 7.32(免费)。


  1. Install Git on remote Windows PC. 在远程Windows PC上安装Git。 [Probably optional: Check version of git on Mac (git -- version in Terminal) and install the same version on remote server. [可能是可选的:在Mac上检查git的版本(git –终端中的版本),然后在远程服务器上安装相同的版本。 In SourceTree on Mac, select this version (Preferences -> git ) ]. 在Mac上的SourceTree中,选择此版本(Preferences-> git)]。

  2. In Terminal on Mac, use ssh-keygen to create a private/public keypair in /Users/bill/.ssh/id_rsa.pub Remember the passphrase. 在Mac上的Terminal中,使用ssh-keygen在/Users/bill/.ssh/id_rsa.pub中创建一个私有/公共密钥对。记住密码。

  3. Configure free BitVise SSH Server on remote server with public key of client, in a local Windows account called bill. 在名为Bill的本地 Windows帐户中,使用客户端的公钥在远程服务器上配置免费的BitVise SSH服务器。 Use 'Open easy settings'. 使用“打开简单设置”。

  4. On remote server, ensure the System path contains c:\\Program Files\\Git\\mingw64\\libexec\\git-core (or similar) thereby allowing access to git-upload-pack and git-receive-pack. 在远程服务器上,确保系统路径包含c:\\ Program Files \\ Git \\ mingw64 \\ libexec \\ git-core(或类似文件),从而允许访问git-upload-pack和git-receive-pack。 (Right-click This PC -> Properties ->Advanced system settings ->Environment variables -> System variables -> Path.) (右键单击此PC->属性->高级系统设置->环境变量->系统变量->路径。)

  5. On the Mac, ensure the remote server is referenced in /etc/hosts. 在Mac上,确保在/ etc / hosts中引用了远程服务器。 Use sudo nano /etc/hosts, do the edit, then sudo killall -HUP mDNSResponder. 使用sudo nano / etc / hosts,进行编辑,然后使用sudo killall -HUP mDNSResponder。

  6. Test SSH from Terminal on the Mac: ssh bill@ineke – this should bring you to the PC command line. 在Mac上的终端上测试SSH:ssh bill @ ineke –这将带您进入PC命令行。

  7. If problems with SSH test, try deleting Users/bill/.ssh/known_hosts. 如果SSH测试有问题,请尝试删除Users / bill / .ssh / known_hosts。

  8. On private Windows server (ineke) create empty directory in login account bill: bill/GitRepositories/Xyz.git/ 在专用Windows服务器(ineke)​​上,在登录帐户bill中创建一个空目录:bill / GitRepositories / Xyz.git /

  9. Right-click on folder bill/GitRepositories/Xyz.git and select Git Bash Here. 右键单击文件夹bill / GitRepositories / Xyz.git,然后在此处选择Git Bash。 Then at GitBash command line enter: git init -- bare (to create empty repository). 然后在GitBash命令行中输入:git init-裸(创建空存储库)。

NOTE: If Git Bash Here is not available, run GitBash.exe and enter git init -- bare ~/GitRepositories/Xyz.git 注意:如果此处没有Git Bash,请运行GitBash.exe并输入git init-裸〜/ GitRepositories / Xyz.git

  1. On Mac, move Xyz directory, containing files involved, to Desktop and, in the place where it was, create an empty directory of the same name (Xyz). 在Mac上,将包含相关文件的Xyz目录移动到桌面,然后在原位置创建一个具有相同名称的空目录(Xyz)。

  2. In the Desktop Xyz directory, delete any and all hidden .git files. 在Desktop Xyz目录中,删除所有隐藏的.git文件。 (Use Terminal -> showFiles/hideFiles to view hidden files : http://ianlunn.co.uk/articles/quickly-showhide-hidden-files-mac-os-x-mavericks/ ). (使用Terminal-> showFiles / hideFiles查看隐藏的文件: http ://ianlunn.co.uk/articles/quickly-showhide-hidden-files-mac-os-x-mavericks/)。

  3. On Mac in SourceTree, click on New Repository > Clone from URL. 在Mac上的SourceTree中,单击“新建存储库”>“从URL克隆”。

  4. On Clone a Repository screen, for Source URL enter ssh://bill@ineke/~/GitRepositories/Xyz.git and then click in Destination Path. 在“克隆存储库”屏幕上,输入ssh://bill@ineke/~/GitRepositories/Xyz.git作为“源URL”,然后单击“目标路径”。 The message 'This is a Git repository' will appear. 将会出现消息“这是一个Git存储库”。

NOTE: If instead you see 'Not a Git repository', check the server's Path. 注意:如果相反,您看到“不是Git存储库”,请检查服务器的路径。

  1. In Destination Path, navigate to the empty Xyz directory, then enter a Name and click Clone. 在“目标路径”中,导航到空的Xyz目录,然后输入“名称”并单击“克隆”。 A local Xyz repository will be created in the Xyz directory. 将在Xyz目录中创建本地Xyz存储库。

  2. In SourceTree create a .gitignore file to exclude unwanted files. 在SourceTree中,创建一个.gitignore文件以排除不需要的文件。 Double-click on Xyz -> Settings -> Advanced -> Edit. 双击Xyz->设置->高级->编辑。 To edit the global ignore list, go to SourceTree -> Preferences -> Git -> Edit. 要编辑全局忽略列表,请转到SourceTree-> Preferences-> Git-> Edit。

  3. Copy all the files in the Xyz directory on the desktop to the empty Xyz directory. 将桌面上Xyz目录中的所有文件复制到空的Xyz目录中。

  4. In SourceTree, double-click on the Xyz repository. 在SourceTree中,双击Xyz存储库。 In the window that opens, click Pending Files then click Commit Message. 在打开的窗口中,单击待处理文件,然后单击提交消息。 Enter a comment and click 'Push changes immediately to origin/master'. 输入评论,然后点击“立即将更改推送到原始/母版”。 Click Commit. 单击提交。

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

相关问题 如何使用XCode或Sourcetree通过VPN访问GIT存储库(在Mac上) - How do i access a GIT repository through VPN with XCode or Sourcetree (on a mac) 如何在Windows上设置git存储库,然后在Mac OSX上从中推送/拉取 - How can I set up a git repository on windows, and then push to/pull from it on Mac OSX 无法使用bitvise SSH将存储库从服务器PC克隆到远程PC - Unable to clone the repository from server PC to remote PC using bitvise SSH 如何使用ssh从本地开发机更新服务器上的git裸存储库? - how to update git bare repository on server using ssh from local development machine? 使用 SSH 从跳机访问 git 服务器 - Access a git server using SSH from a hop machine 如何在 GitHub 上设置私有 Git 存储库? 甚至有可能吗? - How do I set up a private Git repository on GitHub? Is it even possible? 如何通过Git中的ssh从Windows服务器克隆到Mac客户端? - How to clone from a Windows server to Mac client through ssh in Git? 如何在远程Windows计算机上指定git存储库的路径 - How do I specify a path to git repository on a remote windows machine Git如何访问存储库Windows本地机器? - Git how to access repository Windows local machine? 如何在 Sourcetree 中忽略具有 Git 存储库的文件夹中的所有文件? - How do I ignore all files in a folder with a Git repository in Sourcetree?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM