使用 XCode 和 BitBucket 了解 Git

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

Understanding Git with XCode and BitBucket

xcodegitbitbucket

提问by Justin

After following several tutorials I was finally able to take my existing, non-Git-Repository XCode Projectand get it uploaded to a repository on BitBucket. I'm completely new to git but I'd like to start working with versioning. Since I'm a complete newb I'd rather not be working with the command line all day (which is what I had to do to get the project on BitBucket).

在学习了几个教程之后,我终于能够将我现有的非 Git 存储库 XCode 项目上传到 BitBucket 上的存储库。我对 git 完全陌生,但我想开始使用版本控制。由于我是一个完整的新手,我宁愿不整天使用命令行(这是我在 BitBucket 上获得项目所必须做的)。

XCode's organizer now has access to the BitBucket repository. I successfully cloned the project back to my hard drive. My question is this: From now on, will the projects be in sync with each other? I'm not familiar with the lingo, and the difference between a branchand a fork. Essentially, I uploaded a 1.0 codebase and I want to start working on 1.1. I'd like to either forkthe code or branchit so that the original project remains for reference. From what it appears, when I clone to my hard disk, XCode creates a new local repository instead of saving it on BitBucket.

XCode 的组织者现在可以访问 BitBucket 存储库。我成功地将项目克隆回了我的硬盘。我的问题是:从现在开始,这些项目会相互同步吗?我不熟悉行话,也不熟悉branchfork之间的区别。本质上,我上传了一个 1.0 代码库,我想开始研究 1.1。我想对代码进行分叉分支,以便原始项目保留以供参考。从表面上看,当我克隆到我的硬盘时,XCode 会创建一个新的本地存储库,而不是将其保存在 BitBucket 上。

I'm confused, please help!

我很困惑,请帮忙!

采纳答案by VonC

Forking is a server-side operation where you clone the repo. For BitBucket, it is generally used with Mercurial (see "Forking a Bitbucket Repository").
This isn't what you have done.

Forking 是一种服务器端操作,您可以在其中克隆存储库。对于 BitBucket,它通常与 Mercurial 一起使用(参见“分叉 Bitbucket 存储库”)。
这不是你所做的。

You have simply cloned your BitBucket Gitrepo (now that BitBucket also support Git, and not just SVN and Mercurial) into a local repo and imported it in your XCode editor.
You can check it through command-line (git remote) or in XCode (See "Version Control System with XCode 4 and Git").

您已经简单地将您的 BitBucket Git 存储库(现在 BitBucket 也支持 Git,而不仅仅是 SVN 和 Mercurial)克隆到本地存储库并将其导入到您的 XCode 编辑器中。
您可以通过命令行 ( git remote) 或在 XCode 中检查它(请参阅“使用 XCode 4 和 Git 的版本控制系统”)。

Note that you need to use an https address for your BitBucket clone address for being able to push back to the BitBucket repo from your XCode-managed local repo: see "Bitbucket + XCode 4.2 + Git".

请注意,您需要为 BitBucket 克隆地址使用 https 地址,以便能够从 XCode 管理的本地存储库推回 BitBucket 存储库:请参阅“ Bitbucket + XCode 4.2 + Git”。

For more on the basis of Git (especially branches), you can follow first the small labs from gitimmersion.com.

更多关于 Git 的基础(尤其是分支),你可以先关注gitimmersion.com的小实验室。

回答by mestevie

What you want to do is Branch your code from your 'master' i.e. your 1.0, to a 'develop' branch i.e. your 1.1 version. This is the simplest way for you to start getting used to version control. Once you create the branch using Xcode, the project in Xcode you are working on locally will be on that branch.

您想要做的是将您的代码从“master”(即 1.0)分支到“develop”分支,即您的 1.1 版本。这是让您开始习惯版本控制的最简单方法。使用 Xcode 创建分支后,您在本地工作的 Xcode 中的项目将位于该分支上。

As you make changes to the code on that branch, 'commit' them from Xcode, and then 'Push' them up to Bitbucket (all done from the same menu in Xcode File>Source Control>...Xcode will ask during a push which branch to send changes to so make sure you select your Develop branch.

当您对该分支上的代码进行更改时,从 Xcode“提交”它们,然后将它们“推送”到 Bitbucket(所有这些都在 Xcode File>Source Control>...Xcode 的同一菜单中完成要将更改发送到哪个分支,因此请确保选择您的 Develop 分支。

This will keep your local copy and your remote repo in sync as you develop your code.

这将使您在开发代码时保持本地副本和远程存储库同步。

This chapter in the Xcode user guide helped me immensely:

Xcode 用户指南中的这一章对我帮助很大:

https://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/SCM/SCM.html

https://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/SCM/SCM.html

How often you should do the commit and push dance will come from experience.

你应该多久做一次提交和推舞将取决于经验。

Good Luck.

祝你好运。