Using Source Control with git and new projects - iphone

I'm new to SCM and I've managed to create and use a repository for an existing project. By following a variety of posts, I've done the following:
1) Created an account on Assembla
2) Used bash/git in my existing project directory to add, commit, and push the project
3) Used Source Control in XCode to pull, modify, commit, and push changes
Now I want to start a new projection Xcode, and it seems I have to go through the same steps, using a mixture of Xcode 4.2 and bash commands to get the new project into Assembla.
For example, I created a new space on Assembla "newjunk", started a new project in Xcode "newjunk" and did NOT check "create local git repository". I did not run any bash/git commands. In Xcode I cannot "push" because I did not "commit", and I can't "commit" because "no valid working copies were found".
Is this the only way to get a new project into a remote repository?
Or can it all be done from within Xcode, and if so how?
EDIT: Note - I've tried these steps (modified for Assembla and Xcode 4.2) http://www.mindthe.net/devices/2011/04/28/12-steps-to-using-github-with-xcode-4/ which is how I got the "no valid..." message

This helped me a lot
http://helpdesk.assembla.com/customer/portal/articles/678953-setting-up-git-on-windows
I preffered using TortoiseGit

Related

How can I start a project on GitLab repo with Eclipse?

Good morning.
I just create a GitLab private repo to work in a project with some people. When I add GitLab repo to Eclipse, it says there aren't projects (and it's true). I would know how to create a project and sync with online repo so other members can see my project and codes.
I tried to start a project in git\repoName\ folder, then right-click and choose Team->Commit, but changes wouldn't save (in gitLab repo's website, it says "Repo is empty").
I tried to follow some online guides, but without success.
Sorry for bad english!
Eclipse 4.2 and newer, comes default with (E)Git installed. There is a good Eclipse git tutorial from Vogella.
Create a GitLab git repository
Log into GitLab
Create a project / git repository
Copy the https url from the project, used for cloning
Adding an GitLab git repository in Eclipse
Open the Git perspective in Eclipse
Use Clone existing Git repo, as shown in Using git repository view
Now all the git functionality from Eclipse can be used.
I assume you have a cloned repository available in Eclipse (eGit) that is empty. If not, follow the steps in the answer from Verhagen.
By now, you have a cloned repository that is marked with "[NO HEAD]", indicating that no commit has been made.
Start creating a new project by using your project type of choice; I'll use Java project for simplicity: File menu > New > Java project
in the New Java Project wizard un-tick the "Use default Workspace location" checkbox; instead, choose the directory where you cloned your empty GitLab project, and append the name of the project (this is to make Eclipse create a directory inside the repository, just in case you later want to create more projects in the same repo).
Fill in the wizard as you usually do. When you are done with the different steps, you'll have a new project, that is also marked with "[NO HEAD]"
Create some source files you want to share (e.g. HelloWorld.java)
Synchronize workspace (right click on the new project > Team > Synchronize workspace) you will see that now there are files to commit. Pay attention to those files, since some of them ( .gitignore, and maybe .classpath, .project,.settings directory... depending on how you share your projects) you'll want to add to the .gitignore.
right click on the files you want to commit, fill in the commit message and click "Commit and Push". Click Next
Since it is a new repository, you'll have to configure the Push action. I selected HEAD as source and HEAD as destination. You might want to do the same, at least for this first commit+push; later on, you might choose to add some specs for branches, etc.
The Push Confirmation will show you that the new branch master:master will be created.
Both project and repository lost the "[NO HEAD]" marking
You can check gitlab site to confirm your files are there.

Workflow for getting Github repository updates

There are a lot of great open-source projects on github. Most of them come with great sample apps.
Now I go through the following steps to get a repository:
Visit a github repository, e.g. https://github.com/omz/AppSales-Mobile
Click Clone in Mac to clone the project
Open GitHub app in Macbook
Right-click AppSales and select Show in Finder
Open the xcodeproj in Xcode
Modify Bundle identifier in ...-Info.plist file
Modify Code Signing Identity in the target
Compile and run
Whenever there is any update in the repository, I open the Github app and discard changes made in step 6 to 7 above, and sync. Then go though step 6 to 8.
By using the Github app, how can I keep the changes made in step 6 to 7 and also get new updates also?
Use a git client and most of the repetitive tasks you are doing now will just ... go away. Tower is a good choice, but you can always use the command line as well:
git clone https://github.com/omz/AppSales-Mobile.git
cd AppSales-Mobile/
open -a XCode AppSales.xcodeproj/
Run the project, change files, do whatever. Then when ready to get updates from upstream server just do:
git pull (or git fetch, then git merge).
Alternatively you could add the files you are changing to your .gitignore file, so that they aren't tracked by Git.

how to set up an SCM in Xcode 4.x?

hi friends i am facing problems to configure SCM with Xcode 4.x
And can u tell me how to upload my project to remote server from xcode repositories,and i want share the same project from server by using SCM
Xcode acts only as an SCM client for Git and Subversion SCMS. It can create local Git repositories when you create your project, but not Subversion. Xcode does not help you create remote repositories specifically, it only lets you connect to them.
Which SCM system are you using? Git or Subversion (SVN)? Determine which one and follow its instructions for creating shared repositories on remote servers. They're both very different and Xcode can't help you there.
Once you have them set up, you can then let Xcode know about them either by:
1 - Using the command-line tools (git or svn) or your favorite GUI client to check out / clone your remote repository to some working copy / local clone. Then just open the project with Xcode and Xcode should auto-discover the settings.
or
2 - Opening the Repositories Organizer (Cmd-Shift-2, click Repositories tab) and adding the remote repository there.
Finally, if you have an existing Xcode project that is not under version control, you'll need to use the SCM-specific command line or your favorite GUI tool to bring the project under version control and get it into your remote repository in the way required by the SCM system you're using, then follow the above to let Xcode know about it.

Why am I unable to retrieve commited new folder from svn with Xcode 4?

I just started to use SVN with Xcode and stumbled upon several problems. I have started to work with SVN repository that was deployed on a remote server. The project had a standard directory structure (trunk, branches, tags). I have checked out the project with Xcode, did some work, performed commit (from Xcode). The teammate checked out that version. Then using Xcode, I have added new images folder and images to svn repository, and successfully performed commit. I ensure you that the image folder and the images were successfully uploaded to SVN server, because I saw that folder and images in trunk both from Xcode organizer and from browser, when was viewing the project remote files.
Now, my teammate performed update from Xcode (via file -> source -> update) but the image folder and images have not been retrieved. Xcode 4 just showed a message that a "project is up to date". He also went to organizer, then selected the trunk of repository and pressed update button, but the same message about project being up to date was shown. After more several tries, he deleted his local project files and performed checkout, but now the images were successfully retrieved. What might be a cause of such problem?
I know that for all required tasks I might use svn terminal commands, just curious is it sufficient to use Xcode 4 without command line.
We've had several issues with Xcode's SVN and have had to resort to the command line a few times to resolve them. Sometimes restarting Xcode has been enough, but if not here's a few simple svn commands that might help shed light on the issue, execute these from your project's root folder:
To check what state your SVN is in:
svn status
To update to most recent:
svn update
To commit:
svn commit -m "A commit message"

How can I add an existing project as a working copy in XCode 4?

Today I switched from XCode 3 to XCode 4 and now I have a lot of problems with my projects, which were under version control in XCode 3. If you install XCode 4, it will remember all your repositories. The problem is, that the projects don't know, that they belong to a specific repository. The instructions of Apple are easy, but do not work:
If you have a working copy of a project that was checked out of Subversion or cloned from Git using the command line or another tool, you can add it to your Xcode SCM repository support. To do so, click the Add button (+) at the bottom of the navigation pane in the repository organizer and choose Add Working Copy.
If I choose the project directory, I get this:
The working copy could not be added because its repository could not be located.
Does anybody know what the problem is?
To avoid confusion, I want to make a few things clear: my projects were under version control in XCode 3 and it worked. I am also aware of the fact, that I could delete all my projects and check them out (I don't want to do that). I already tried to checkout a project, and then this project is automatically added as a working copy. However if I remove the reference and try to add the same (!!) project as a working copy again, it does not work either.
The key for me was quitting Xcode then following Apple's instructions exactly. In Terminal:
$ cd project_folder # project containing the .xcodeproj file
$ git init
$ git add . # note the dot after "add"
$ git commit -m 'Initial version text'
Then get back into Xcode, open the Organizer, et voilà — instant repository.
I was able to resolve this by quitting Xcode and then opening the repository organizer before opening my workspace. Then it worked and I could open my workspace with SVN integration.
In Terminal, you may get the error:
-bash: git: command not found
This is because the git tool (and svn too) are contained inside the Xcode.app bundle in XCode 4.5 or later. In order to run the contained tools you need to use the xcrun command. For example, to run the git commands mentioned in the posts above:
$ xcrun git init
$ xcrun git add .
$ xcrun git commit -m 'Initial
version text'
For more info, see this link:
http://www.cocoanetics.com/2012/07/you-dont-need-the-xcode-command-line-tools/
What I had to do was, as Udi pointed out, close Xcode and open the organizer before opening any projects. But then I had to add the repository and it's credentials first (SVN, in this case) before following the Apple directions you (mowidev) posted. After doing this, the working copy then appeared inside the listing for the SVN repository I'd added.
That ultimately linked in the two (Xcode project source control settings with the existing working copy it was using). Anything out of order ended up with Xcode thinking it was a Git repo (that also didn't exist).