Understanding Git with XCode and BitBucket - xcode

After following several tutorials I was finally able to take my existing, non-Git-Repository XCode Project and 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).
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 branch and a fork. Essentially, I uploaded a 1.0 codebase and I want to start working on 1.1. I'd like to either fork the code or branch it 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.
I'm confused, please help!

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.
You have simply cloned your BitBucket Git repo (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").
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".
For more on the basis of Git (especially branches), you can follow first the small labs from gitimmersion.com.

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.
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.
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:
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.

Related

How to use GitHub in VS 2015 so a moron can understand?

Downvote if you want... but I need a set of simple basic steps that we can follow. We have VS Enterprise, no GitHub add-ons installed. We have a an empty repo created on GitHub. What do each of the developers do after that? There's a local repo, right? Should there be another project on the local machine that commits to the local repo or do we open the project in the repo? If yes, how do we create that other project? What about the .sln file that VS lovingly puts in a separate folder? We have been at this for hours and believe me we have tried every combination of commit/push/sync/goat sacrifice except the right ones. We cannot reproduce consistent results such that two developers can work against the same remote repo. Sometimes one developer can push and he doesn't see the files pushed by the other developer. Sometimes the Commit Message text box lights up but the Commit button is disabled. I thought I was reasonably intelligent until I started working with GitHub.
I'll give you the broad steps you need to do. You may need to fill in a bit of the detail. THis is how I would work it. I am sure you could get many other opinions.
Create the repo on GitHub (which You already have done.)
Each developer should then go to the GitHub repo and fork the repo under their own GitHub account.
Each developer then needs to clone their repo to their local machine. (That's the beauty of Git. Every developer has the entire repo locally.) You can do this in VS2015 by choosing: File -> New -> Repository -> Clone.
Go to your on-line repo and get the URL of the repo that you will be cloning. Enter it into the New Repo dialog box in VS.
When working on the project, each developer should create a temporary feature branch, which they push to their own GitHub repo. They can then push their work as often as they want without it conflicting with other developers.
When a developer thinks that their work should be merged into master, they should go to GitHub and issue a "Pull Request" for their feature branch.
Their PR can then be discussed among the team before it is accepted.
Once it is accepted and merged into master, the developer can delete their feature branch locally and on GitHub, if he likes.
Since "master" on the team repo has now been updated, each developer will need to pull down master from the team repo to update their own local and remote repos.
It sounds more like an how-to-use git issue. You probably first need to see how two collaborators work on same project with git. I donot think either VS or GitHub has anything to do here, as both only provides you git gui tool regarding this issue.

How to pull files from github branch to xcode directly?

I have a project created for me by teacher and I have to improve it. He created a repo on Git Hub with branch for me. I'm trying to pull the project files from that branch directly to Xcode and Xcode refers to the branches that I have created which are empty, not the master one. Can't find any adequate manual for that as well... Please help...
so github uses git to manage repositories, so this question has more to do with git than with github.
Git is a distributed-repository source-control system, which means that every machine has a full copy of the repository, with all of its history and branches. This means that your local repository that you cloned from GitHub has all of the branches on it.
So, your problem is actually just that you need to switch branches locally to the branch your professor created.
In a terminal you can execute
git checkout <the-name-of-the-branch-your-teacher-created>
and that should do it. :)
Xcode is simply looking at the files in your working directory, so switching branches will update the files in Xcode as well.
For more git information check out the git book or any of the other countless git resources online!
Well using Git is fairly simple and as specified above can pull the project (either complete of specific brach and then import it.
OR
While running Xcode you can follow below steps -
Click on Check out an existing project.
Enter Repo link as shown below and hit Next.
Select the branch that you want to pull and hit Next.
Note As shown in Image Xcode version 8.2.1 is used.

Adding an iPhone Project to an existing Github Project

I'm working on a bit of documentation code for an API project.
Someone else already has an existing github account where some people have already submitted a few projects. I will call it {http://github.com/monkeyhouse/}
I've created a project in Xcode (iPhone app), and have that stored under my normal Xcode git, which is backed up everything is fine.
What is the right bit of git foo that I need to put Xcode Project into
{http://github.com/monkeyhouse/examples/iPhoneClient}
I've tried creating a symbolic link to the project on my machine and that didn't work.
Following is a common way to do what you're wanting to do on Github:
Fork http://github.com/monkeyhouse/ under your own Github account.
Clone your forked version of the repo to your development machine.
Make the modifications you want directly to your cloned repo (e.g., don't use a symlink), adding examples/iPhoneClient to the local repo, and commit the changes.
Push your changes to your public Github fork of http://github.com/monkeyhouse/.
Submit a pull request with http://github.com/monkeyhouse/ to have them bring in the changes you pushed to your forked version if they're happy with them.

Including a cloned repo in a git repo

I'm writing an app in xcode, and I'm using git (though using the github app to commit and manage it, not xcode) for version control.
I use PXSourceList in the project, which I've cloned to my computer. I include the files as references in Xcode, so this means they aren't part of my git repo which syncs to github. So if someone were to download or clone from github they wouldn't be able to build without getting PXSourceList themself. How do I include PXSourceList, so that it is "referenced" in my repository?
Both on my computer (to my local clone) and on github (to PXSourceList on github)? So that PXSourceList will stay up to date in my repo when changes are made to it by others independant of my repo?
Subrepo or git-subtree. You have to move PXSourceList into your project tree in both cases

Loading Xcode 4 git repository onto Bitbucket

I have an Xcode project with a few commits, and now I would like to load it onto Bitbucket, without losing my commit history. What would be the best way to do this?
Create a new repository, and push to it from Xcode like normal. It will preserve all of the commit history.
You could follow the Import Code into (BitBucket) repo, and select a Git repo on your local workstation.
The fact that this local repo is managed by XCode4 doesn't matter.
After the import, you can add your Bitbucket repo as a remote, with an https address, as mentioned in "Bitbucket + XCode 4.2 + Git" (even though the XCode GUI might not be enough, and some command lines might be needed).

Resources