如何用Xcode6.1sourcevba controlsource

怎么设置xcode可以提交代码到git_百度知道
怎么设置xcode可以提交代码到git
提问者采纳
6&#65533.pbxuser  ;staff &nbsp.hiphotos.://d;1768 &nbsp.DS_Store&#65533,这时我们再用git status命令查看当前状态:新建一个文件; 7 YiBan &/zhidao/wh%3D450%2C600/sign=4db423e93e87edfaed24b899a901f20b.json  new file://d; /zhidao/wh%3D600%2C800/sign=32c952e1ffedabc70683fb/838ba61ea8d3fd1fd7f28eca5f24,命名为.strings  现在进行提交,新建一个repository(网页右上方). 408 &nbsp! : &nbsp.xcassets/LaunchImage.jpg" />  首先必须有GitHub的帐号.baidu。但是如何在Xcode中上传代码至GitHub呢..moved-aside  DerivedData  ; ManualGitDemoTests/en:<img class="ikqb_img" src="5 12 16.://d:  (use &quot:10 .staff &nbsp.m  Push。我们可以用Xcode提交代码.storyboard  create mode 100644 ManualGitDemo/Images,之后会被要求填写密码,,前往Xcode中.baidu://d: & to track)  这里看到已经没有; ManualGitDemo/Images.jpg" target="_blank" title="点击查看大图" class="ikqb_img_alink"><img class="ikqb_img" src="http.hiphotos,现在,具体做法是;staff &nbsp.perspectivev3  xcuserdata  profile  *://g.baidu.,: &nbsp:ManualGitDemo YiBan$ git status  On branch master  Initial commit  Untracked files.xcodeproj/project.git/  使用  git init  来初始化一个空的git仓库:  # Xcode&#65533,然后Source Control-& 9 YiBan &nbsp.staff &nbsp  几乎所有iOS程序员都上过GitHub寻找开源类库,记得要勾选Create&nbsp.hiphotos.hiphotos,GitHub使用了公私密钥.com/zhidao/wh%3D450%2C600/sign=a8f4ea357baa091fddd8ca7efce1b62e7. to track)  说明初始化成功了;file& ManualGitDemo/B  [master (root-commit) 83bbefc] Initial  17 files changed.hiphotos,也可以用命令来提交;git&nbsp,会默认在工程中创建git&nbsp://b,此时的SSH keys就生成好了,你的工程已经添加成功了~: &nbsp.launchimage/Contents: &6&#65533;staff &nbsp.DS_Store忽略了.com/zhidao/pic/item/4ec2ddd8ca7efce1b62e7.  此命令先将文件添加至暂存区域:  YiBantekiiMac-3.hiphotos,这样我们目录中就多出一个,然后使用文本编辑器输入以下信息.jpg" esrc="http:  YiBantekiiMac-3.hiphotos.h  create mode 100644 ManualGitDemo/ViewController,之后选/zhidao/wh%3D450%2C600/sign=489cc44e524eeeaa9b2fd6e/befbf2b41d,你可以将它添加到你的账户中  2,然后填写title和key:  YiBantekiiMac-3.git则是启用了Source Control自动生成的目录,则是这样的.?我们可以使用命令行来开启此功能,如果有id_rsa,显示出了未被追踪的文件。  SSH创建过程是这样的.strings  /zhidao/pic/item/86dfaed24b899a901f20b.hiphotos.baidu.pch   ManualGitDemo/main.gitignore   ManualGitDemo://d.baidu.hiphotos,说明.pbxuser  *,如下图所示.com/zhidao/wh%3D600%2C800/sign=19825e0abd12c8fcb4a6fecbcc33be7d/4ec2ddd8ca7efce1b62e7.plist  new file.baidu:10 ;Configure: &nbsp:06 ;git add&quot.git  drwxr-xr-x &5 12 16:ManualGitDemo YiBan$ git status  On branch master  nothing /zhidao/wh%3D450%2C600/sign=ca72dfc9a8f25a81f30e924ba061d950a7bf6b7.gitignore  create mode 100644 ManualGitDemo.jpg" esrc="http,你的SSH Key就和GitHub账户绑定了  前往个人主页,因为那文件对我们没有任何用处: &nbsp,代码都已经提交完毕了.appiconset/Contents.git.xcodeproj/  ManualGitDemo/  ManualGitDemoTests/  nothing added to commit but untracked files present (use &quot.jpg" esrc="http.baidu.lproj/InfoPlist.perspectivev3  : &Initail&quot,然后我们手动创建git管理; ManualGitDemo/ManualGitDemo-Info。不过我们并不希望把,然后选创建,你讲得到&quot,使用git commit -m &quot, working directory clean  好了.strings  create mode 100644 ManualGitDemo/main://h.mode1v3  ://h,说明你已经有SSH keys了;5 12 16.xcodeproj/project:  ssh-keygen -t rsa -C &git add &lt.pub(名字可能会不同).ssh:<img class="ikqb_img" src="http:ManualGitDemo YiBan$ git commit -m &quot.xcassets/AppI 238 &nbsp,.plist  52 YiBan &nbsp://g.jpg" />  现在我们已经在工程中启用了Source Control.History:  YiBantekiiMac-3.xcworkspacedata  create mode 100644 ManualGitDemo/AppD 170 & ManualGitDemo/en,会看到repository的链接.; to include in what will be committed)  .& to include in what will be committed)  :  YiBantekiiMac-3.baidu://h.m  12 YiBan &nbsp.json  create mode 100644 ManualGitDemo/I5 12 16.baidu,并且还要创建SSH.DS_Store和;git add&quot.pbxproj  create mode 100644 ManualGitDemo,随便写什么都可以,我们可以忽略它:<img class="ikqb_img" src="http。然后工程新建完成后.xcassets/LaunchImage,的确:  (use &quot.m  new file.m  create mode 100644 /zhidao/pic/item/befbf2b41d..com/zhidao/wh%3D600%2C800/sign=2a61af1a3ef33a879e3c00/ba061d950a7bf6b7; ManualGitDemoTests/ManualGitDemoTests.xcodeproj/  ManualGitDemo/  ManualGitDemoTests/  nothing added to commit but untracked files present (use &quot://b:  1,此时你可以通过命令生成出来.,GitHub上有大量优秀的开源类库供大家学习://g.xcworkspacedata   ManualGitDemo/ViewController:ManualGitDemo YiBan$ git status  On branch master  Initial commit  Untracked files:06 。现在可以提交了;YOUR EMAIL&quot: &5*.com/zhidao/pic/item/838ba61ea8d3fd1fd7f28eca5f24,输入Name(你工程的名字)和Address(之前的链接地址).gitignore已经把.storyboard  new file.jpg" />  把链接赋值下来: &nbsp.plist  create mode 100644 ManualGitDemoTests/ManualGitDemoT1 YiBan &/zhidao/wh%3D450%2C600/sign=ee36ee2cabcd8e2ddef49b73/838ba61ea8d3fd1fd7f28eca5f24, 803 insertions(+)  create mode   */build/*  &#65533: &6&#65533.gitignore  ManualGitDemo.hiphotos.gitignore. 在命令行输入cd ~/,这样就可以使用git来管理工程版本了  但是如果我们想对一个未启用git的工程加入git的功能怎么做呢.lproj/Mgit add &lt: &nbsp.strings  再查看下状态:06 ManualGitDemo.plist  create mode 100644 ManualGitDemo/ManualGitDemo-P 5 YiBan &nbsp.mode2v3  *:UseGit YiBan$ cd /Users/YiBan/Documents/iOS_Dev/ManualGitDemo  YiBantekiiMac-3;命令: &nbsp.lproj/Main,但还没有提交; ManualGitD.h  new file?  首先我们新建一个工程; to unstage)  new file.lproj/InfoPlist,看看此文件夹下有哪些文件.xcodeproj/project.lproj/InfoPlist:  (use &quot.hiphotos.gitignore文件了.hiphotos,选择刚刚新建的链接!default.jpg" />  Add Remote中.com/zhidao/pic/item/95eef01f3a292df59a7c.jpg" />  如果没有使用Source Control..hiphotos.jpg" />  输入Repository name和描述,现在使用ls-la命令查看目录下的所有文件(包含隐藏文件)  total 16  drwxr-xr-x &nbsp.pub或者id_ ManualGitDemo/AppD5  ; 306 &nbsp,Push~  现在刷新下GitHub主页,会要输入一些信息.baidu://c: &nbsp.m  create mode 100644 ManualGitDemoTests/ManualGitDemoTests-INo such file or directory&quot,确保与你的电脑通讯过程是安全的.jpg" target="_blank" title="点击查看大图" class="ikqb_img_alink"><img class="ikqb_img" src="http://c.DS_Store  ManualGitDemo.xcworkspace/contents.hmap  保存至工程文件夹中。使用Xcode可以查看提交的历史纪录,引号内的内容是提交的注释.DS_Store了.pch  create mode 100644 ManualGitDemo/ViewController.xcodeproj/ 5 YiBan &nbsp.json  new file,有了SSH Keys后将其添加至你的GitHub账户中就可以了,此时我们没有开启Source Control.jpg" esrc="/zhidao/pic/item/ba061d950a7bf6b7.launchimage/Contents
资深电脑人
其他类似问题
为您推荐:
xcode的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁理解 XCode 中的 Git 版本控制 - 开源中国社区
当前访客身份:游客 [
理解 XCode 中的 Git 版本控制
英文原文:
The git repository is ready, but if you go back to Xcode and open the Source Control menu, you’ll find out that everything is still disabled.
That’s because Xcode doesn’t get notified automatically about our manual git repository addition. So, close Xcode using the menu Xcode & Quit Xcode and re-open it. Now, in the NoGitExample project if you open the Source Control menu once again, you’ll see that all options have been enabled, just like if we would have added the git repository along with the project creation.
At this point feel free to close the NoGitExample project and delete it from your Desktop as well.
Now you know how to add a git repository for every project of yours, and even if you intentionally or accidentally you don’t add one during a project setup, you can do it manually at any given time.
git repository 已经准备好了,但是如果你回到 Xcode,打开 Source Control&菜单,你会发现一切都还是不可用的。
这是因为 Xcode 不会自动被通知到,我们已经手动添加了 git repository。因此,点击菜单&Xcode & Quit Xcode 来关闭 Xcode ,然后再重启。现在,在&NoGitExample&项目中,如果你再打开&Source Control&菜单,你会看到这些的选项都可用了,跟我们创建 project 时就添加了 git repository 的效果相同。
到了这一步,就可以关闭这个 NoGitExample 项目,也可以把它从桌面上删除了。
现在你已经能够知道怎么为一个 project 添加 git repository了。并且即使你在创建 project 时有意或无意没有添加 git repository,也可以随时手动添加。
Committing Changes
When talking about committing changes to a repository, we actually mean to store a new version of our project containing all changes that have been made to it, such as modified or newly added files. Generally, a commit should happen when a remarkable amount of work is done, and the project exists in a stable state. There’s not any general rule about how often a commit should be done, but I would suggest you that: If you think that the work you’ve done since the last time you committed any changes to the repository will cost a lot in time and effort if you ruin it by accident along the way, then it’s definitely time for a new commit.
Xcode by default makes an initial commit once a new project gets created. The purpose of it is to keep a version of the project at its initial state. That happens behind the scenes, without disturbing you or asking for any kind of confirmation from you. If you don’t add a git repository when creating a new project, but you do so later manually as shown in the previous part, the initial commit is preformed with the command: git commit -m ‘Initial commit’ that we previously used.
说到所谓的“提交更改到 repository”,我们实际的意思是:存储我们项目的一个新版本。新版本包含目前已作出的所有更改,比如代码修改或者新添加的文件。一般来说,一次提交应该发生在一定量的工作已经完成,并且项目处于稳定状态之时。关于提交的频率应该是多久一次,并没有一定之规,但我建议:如果你认为从上一次提交到现在之间,你所做的工作如果意外丢失,会造成巨大的时间精力浪费,那就一定要提交一下了。
Xcode 默认会在新项目创建时做一次初始提交,目的是保存一个项目初始状态的版本。这次提交是在幕后完成的,不会打扰你,也不会要求你确认。如果你在创建项目时没有添加 git repository,是如前所述在之后手动添加的,初始提交是通过这个指令完成的:git commit -m ‘Initial commit’&我们之前用过这个指令。
Actually, you can see information regarding the initial commit if you go to the Source Control & History… menu. In there is recorded every commit you perform to the project.
Let’s see a little bit action now, and let’s do some modifications to the project. Go to the ViewController.m file, and in the private class section add the next property declaration:
@interface ViewController ()@property (nonatomic) int@end
Next, modify the viewDidLoad method as shown right next:
123456789101112
- (void)didReceiveMemoryWarning{& & [super didReceiveMemoryWarning];& & // Dispose of any resources that can be recreated.& & int a = 5;& & int b = 10;& & self.sum = a +& & NSLog(&The result is: %d&, self.sum);}
If you take a look at the Project Navigator pane, you’ll notice that next to the ViewController.m file, the M letter has been added, just like it’s shown the next figure:
This means that the file has been modified, and there are changes in comparison to the last committed version of it. Generally, every time you modify a file the M letter indicates that there are new changes, not committed yet.
实际上,你可以看到初始提交的相关信息,只需点击菜单&Source Control & History…&。在这里记录了你对项目的每一次提交。
我们现在来尝试一些操作吧,首先要对项目做点改动。来到&ViewController.m&文件,在 private class 部分添加以下的 property 声明:
@interface ViewController ()
@property (nonatomic) int
接下来,修改&viewDidLoad&方法如下:
1 2 3 4 5 6 7 8 9 10 11 12
- (void)didReceiveMemoryWarning { & & [super didReceiveMemoryWarning]; & & // Dispose of any resources that can be recreated.
& & int a = 5; & & int b = 10;
& & self.sum = a +
& & NSLog(&The result is: %d&, self.sum); }
如果你看一眼&Project Navigator&(即左边栏),你会注意到在&ViewController.m&文件后面,多了一个字母&M,如下图所示:
这意味着这个文件已经被修改了,并且相比上次提交的版本确实有改动。一般来说,每次你改动一个文件之后,字母&M&就表示已有改动,还未提交。
Let’s see now how to commit. It’s very simple, and it only takes to open the Source Control & Commit… menu. The following window appears:
Let’s see what it tells us, step by step. At the left pane (indicated with the number #1 in the figure), they are listed all the files that have been modified. In our case, only the ViewController.m has been changed, therefore it’s the only one displayed here. If you pay a close attention, you’ll see that there is a check box at the left side of the file, which is checked by default. If you uncheck it, the changes to file won’t be committed, but now that’s not something we desire, so let it be checked.
In the middle area of the window (indicated as #2), there are two preview panes. At the left one, there is the current version of the file (not yet committed), and at the right one there’s the last committed version of the same file. In this screenshot, as the only commit that has been done was the initial one, it’s depicted the original state of the ViewController.m file.
让我们来看看怎么提交代码。这是很简单的,仅需要打开Source Control &&Commit菜单,如下窗口所示:
一步一步的让我们看看它告诉了我们什么。在左边方框(在图片中标识为#1的部分),这儿列出了所有已修改的文件。在我们的例子中,仅仅ViewController.m文件被修改,因此仅仅显示了一个文件。如果你仔细观察,你将看到文件的左侧有一个缺省选中的复选框。假如你不选中它,已经修改的文件将不会被提交。但是现在这不是我们想要的东西,因此让它被选中。
在窗口的中间位置(标识为#2的部分),有两个预览框。左侧是文件的当前版本(没有提交的),右侧是文件的最近提交的版本。截图描绘了ViewController.m文件的原始状态。
The blue areas at the left pane, ending as lines at the right (indicated as #3), are the actual changes that were made to the file. That kind of representation makes immediately clear all modifications, and to the point (line numbers) they were made. If you notice, at the center of the window, between the two preview panes, there are some small rounded labels, with a number on them (indicated as #4). These labels count the total changes one by one, and that’s the meaning of the numbers on them. At the left of them, there is a checkmark symbol. When that checkmark appears, then the respective change will be normally committed to the repository. However, you can skip to commit one or more specific changes of a file, or even discard them, if you click at the small down arrow at the right side of the number. A small menu with two options is displayed:
If you select the Don’t Commit option, the checkmark symbol is replaced by a stop symbol, and the respective change won’t get committed to the repository.
If you select the Discard Change option on the menu, a confirmation window will appear notifying that the selected change will be reverted, and there’s no way to undo that.
If you click on the OK button, the modifications made to the selected area will vanish, like they were never happened.
左栏的蓝色区域(图中标识为#3的部分),在右栏变成一条线,这显示了文件中的实际改动。这样的表示法让所有的改动一目了然,并且能对应到改动的具体位置(行号)。也许你注意到了,窗口的中央,在两个预览栏之间,有一些小的圆角标签,上面写着数字(图中标识为#4)。这些标签一个一个地数出了全部的改动,上面的数字就是计数的序号。在数字左边,有一个对勾符号。如果出现了这个对勾,说明对应的改动可以正常提交到 repository。尽管如此,你还是可以选择跳过,暂时不提交文件的某一个或几个改动,甚至抛弃所做的更改,只需点击数字右边的小下三角。含有两个选项的小菜单将会浮现:
如果你选择&Don’t Commit&选项,对勾符号会换成禁止符号,对应的改动就不会提交到 repository 了。
如果你选择菜单中的&Discard Change&选项,会出现一个确认窗口,提醒你选中的改动将会被回滚,并且回滚是无法被撤销的。
如果你点击 OK 按钮,响应区域中的改动会消失无踪,仿佛从没来到世上。
If you pay close attention to the commit window image above, you’ll see that all modifications are considered as changes by Xcode, even a blank line. Actually, blank lines are Enter characters not visible on-screen, so it’s totally reasonable to be added to the collection of changes.
Anyway, for the sake of the example, make sure you don’t discard any change, and you allow everything to be committed, so you must be watching the checkmark symbol on each change label.
Under the two panes there is a white area, writing Enter commit message here at the middle of it. This area is provided to add a short description about all the changes made in this version. Click on it and add the contents shown to the next image:
Writing commit messages (that make sense) is useful, especially if you begin committing a lot. So, think of it as a necessary action.
如果你有留心观察上面的提交窗口截图,你会发现所有的修改都会被 Xcode 认为是改动,即使一个空行也不例外。事实上,空行是屏幕上不显示的换行符,所以它被收集为一项改动是合情合理的。
总之,对于这个样例,确保你没有丢弃任何改动,允许一切都提交。因此你应该看到所有的圆角 label 上都有对勾。
在这两栏之下是一片空白区域,中间写着“Enter commit message here”。这个区域用来附加一些简短信息,描述这个版本所做的更改。点击它,填上下图所示的内容:
填写(有意义的)提交信息至关重要,尤其是在提交次数很多的情况下。所以,要把它当做不可或缺的一步。
Now that we have made a tour to the essentials of this window, it’s time to do our first commit. At the bottom-right corner of the window, there’s a button saying: Commit 1 file.
In this button the total number of files to be committed always appear. Click it and congratulations! Your first commit is real, and now belongs to history, both metaphorically and literally. What do I mean? Just open the Source Control & History… menu, and you’ll see it listed there.
As you see, the message we wrote is appeared there, as well as the number of the modified files. In the initial commit made by Xcode, all files were committed, but now just the one we modified.
Besides that, if you close the history window and look at the Project Navigator pane, the M indication next to the ViewController.m file has gone too!
既然我们已经浏览了一遍这个窗口的主要内容,下面我们来做第一次提交吧。在窗口的右下角,有一个按钮写着:Commit 1 file.
在这个按钮里,总是会写着提交的文件总数。点击它,然后恭喜!你的第一次提交已经诞生,将会永久载入历史,不仅是你个人的历史,也是 git 的历史。这是什么意思呢?只要打开菜单上的&Source Control & History…,就可以看到它列在这里。
如你所见,我们之前写的提交信息以及改动的文件总数都出现在这里了。在 Xcode 做出的初始提交中,提交了所有文件;但是我们只改动了其中一个。
除此之外,如果你关闭 history 窗口,再看看&Project Navigator&左边栏,ViewController.m&文件旁边的 M 字母也消失啦!
Now, let’s get prepared for one more commit. This time, we are going to add some new files to our project, and the best way to do that is by creating a new class. So, press the Command-N keys combination to your keyboard, and add an Objective-C class. Make it a Subclass Of the NSObject class, and name it TestClass. Finally, add it to the project.
Once you’ve finished doing all the above, notice in the Project Navigator pane that a new indication with the letter A is appeared next to the two class files. This means the these files have been added to the project, and of course, that they haven’t been committed yet.
Open the ViewController.h file, and just import our class:
#import &TestClass.h&
Next, open the ViewController.m file, and declare a private property as follows:
@interface ViewController ()@property (nonatomic) int@property (nonatomic, strong) TestClass *testC@end
现在,我们准备再做一次提交吧。这一次,我们来为项目添加一些新文件,最好的方式莫过于创建一个新类。那么,按下键盘上的 Command + N 键,然后添加一个&Objective-C class。把它设为&NSObject&的子类,命名为&TestClass。最后,添加到项目中。
一旦上面这些都完成了,注意左边栏&Project Navigator&中的两个类文件旁边都出现了一个字母&A&;意思是这两个文件是后添加到项目中的,因此自然它们还没有被提交过。
打开&ViewController.h&文件,然后 import 我们的类:
#import &TestClass.h&
接下来,打开&ViewController.m&文件,如下声明一个 private 属性:
1 2 3 4 5 6 7
@interface ViewController ()
@property (nonatomic) int
@property (nonatomic, strong) TestClass *testC
Look again on the Project Navigator, and notice that there are four files this time not committed. The two class files we added a while ago, and the two modified existing files. Let’s commit those changes as well, therefore open the Source Control & Commit… menu.
This time, there are five files in total selected to be committed. The fifth (presented first in the row) is the project settings file, automatically modified by Xcode when the new class was added to the project. If you click on the TestClass.h or TestClass.m file, the pane on the left will appear without a content, as shown here:
That happens because there isn’t a previous commit regarding both of these files, so there’s no prior version to compare with. So, seeing the right pane simply writing File was added is absolutely normal.
再看左边栏 Project Navigator,注意到现在有4个没有提交的文件了。两个类文件是我们刚添加的,还有另外两个本来就有的文件。我们需要将这些改动也提交,因此打开&Source Control & Commit… 菜单。
这一次,选中了5个有待提交的文件。第5个文件(显示在第1行)是项目的配置文件,是在添加新类时由 Xcode 自动修改的。如果你点击&TestClass.h&或&TestClass.m&文件,左(译者注:原文可能笔误,此处应该为“右”)栏会变为一片空白,如下图所示:
这是因为这两个文件之前没有提交过,因此没有之前的版本可以对比。所以,右栏里只写着“File was added” 就是再正常不过的了。
Go to the message area and add the next commit message: TestClass class was added to the project.. After that, click on the Commit 5 files button and let Xcode commit the changes to the git repository.
The second manual commit was successfully made. You can check this if you open the commit history from the Source Control & History… menu:
Comparing Versions
After you have committed various versions of your project, is quite easy to compare them and track down code modifications. Comparing versions is especially important when newly added code doesn’t work as it was expected and you need to find any changes been made since the last stable version.
To compare two different versions of a file, either use the View & Version Editor & Show Version Editor, or click on the Version Editor button existing on the toolbar, as shown below:
来到提交信息区域,填写提交信息: TestClass class was added to the project。完成之后,点击&Commit 5 files&按钮,让 Xcode 提交更改到 git repository。&
第二次手动提交已经顺利完成了。可以打开提交历史来验证,在菜单&Source Control & History… 中:
在你提交了多个版本之后,对比各个版本、跟踪代码的变化是非常容易的。当新添的代码不能如预期工作时,版本对比显得尤为重要,因为你需要找到从上个稳定版本以来的所有变化。
要比较两个不同版本的文件,或者点击菜单里的&View & Version Editor & Show Version Editor,或者点击工具栏上的&Version Editor&按钮,如下图所示:

我要回帖

更多关于 sql source control 的文章

 

随机推荐