How do I configure Git in Xcode to work with BitBucket - iphone

I have a project which I have been on for ages which is not connected to any source code repository.
I want to start using BitBucket now, however I am not sure how to go about it. I have created a project in BitBucket.
Should I now clone and check out in Xcode or should I add a repository in xcode. Anyone have any idea?
I have tried cloning using the URL from bitbucket but it just comes back with an error in Xcode

I've met the same problem and here's how I solved it:
(Assume your project is not already under local source control) Create a new project under LOCAL source control (Please note that adding remote source control at this stage may not be successful)
Make this new project a clone of your old project - drag files, add frameworks, etc.
In menu "Source Control" -> -> "Configure "
In the new window, click on "Remotes" -> "+" -> "Add Remote"
Name: anything (you can use "BitBucket")
Address: https://accountname#bitbucket.org/accountname/reponame.git
"Source Control" -> "Commit"
Select "push to remote" at the left bottom corner
Click "Commit"
Check on BitBucket website to see if it's actually pushed to it

As of 2017, xCode now automatically creates repositories for new projects. To push to a new BitBucket repo, go to 'Source Control' > 'Commit...' in xCode and make your first local commit.
Next open a terminal and navigate to to the top-level directory of your project. If you ls -a in here you should see the .git/ directory has been created. In the same directory, add your remote repo with the following (replace with your username/team name and repo name):
git remote add origin https://USERNAME#bitbucket.org/USERNAME/REPO_NAME.git
Go back into xCode, go to 'Source Control' > 'Push...'. You'll be prompted to enter your BitBucket password. Press OK and you're done! Source control commands will now be working within xCode.

I did that through command line and it is fairly straightforward.
create a new repo on bitbucket
assuming your xcode project is not under local git version control yet
go to command line, cd to your xcode project directory, and the follow the bitbucket doc: https://confluence.atlassian.com/display/BITBUCKET/Import+code+from+an+existing+project
git init
git remote add origin git#bitbucket.org:<user_id>/<repo>.git
git add .
git commit -am 'init commit'
git push -u origin master
go back to xcode and you should be able to interact with bitbucket through xcode from this point on

Using the following URL structure
https://accountname#bitbucket.org/accountname/reponame.git
(Taken from here) did the job for me

It is easier to:
create your local Git repo through XCode and add your code there
in command line, add the remote 'origin' toward your BitBucket repo, along with your ssh credentials (in ~/.ssh/config): see
"Bitbucket + XCode 4.2 + Git".
"Using the SSH protocol with bitbucket"
do at least one "git push myrepo origin master" to initiate the first push

This link helped me, I will also copy and paste the instructions in case the link goes away.
http://sketchytech.blogspot.com/2016/02/send-xcode-project-to-bitbucket.html
Sending a non-git Xcode Project to BitBucket from GitHub is the most popular place to host your repos but if you are looking for a free service for teams that are 5 members or less then take a look at BitBucket. Here are instructions for moving a local Xcode project onto BitBucket. (Note: if you opted for a local Git when you created your project you should be able to skip steps 3 and 4.)
-Sign-up for BitBucket and create a repo
-In Xcode go to Source Control menu
-Select "Create a working copy ...."
-Select project and press Create in dialog window
-Return to Source Control menu and select -> Configure ...
-Click "Remotes" tab
-Press add "+"
-Copy and paste the https address you see at the top right of your repo page into the remote location in Xcode
-Go to Source Control menu and select Push... to upload the project
Pushing code updates to BitBucket
Now you have it set up whenever you want to push code to the project:
-Go to Source Control menu and select Commit
-Write a commit note and uncheck anything not to be included in the commit
-Return to Source Control menu and select push
-Select the correct branch and Push
Pulling code down from BitBucket repo
To get code provided by others down from BitBucket:
-Go to Source Control menu and select Pull.

I use SourceTree and Xcode 6.1 and in my case I first create a repository on bitbucket, then I clone my repository on an empty folder (using SourceTree or via command line) then when you create the new project on XCode in that folder, you can commit push and pull normally from XCode

I found this youtube video and it helped me a lot, used this Atlasssian help for ssh authentication, and encountered an Xcode problem for which the solution can be found in this page.

Most simplest way is go to
Xcode > preference > #accounts > click '+' button on corner left
... then this popup will appear ...
just click Bitbucket Cloud ...
Enter ID with password...
And that's it...

Related

Egit: Right click not showing GIT commands

I can't see the GIT commands when using right click on any files in a GIT repository.
I'm using Eclipse-Luna, A fresh install, afeter trying different versions of EGIT.
Thanks,
Elyahu
Some screen shots of the preferences:
I can't see the GIT commands when using right click on any files in a GIT repository.
You must first share that local project in order to make it recognized as a Git repository.
See "How make Eclipse/EGit recognize existing repository information after update?",but don't forget, once shared, to close/reopen your project.
Then Git will be active on said project.

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.

Commit an entire Netbeans project on sourceforge

I have my own PHP project in NetBeans. Afterwards I have registered a sourceforge account. Now I would use sf's git repository for versioning my code.
What I need now is to send the entire project on the repository, using netbeans. How can i do that?
Assuming you are on SourceForge's latest platform i.e. Allura, you first need to create a Git repository on SourceForge.
(You might have already done this when you first made project)
Following are the step to create git repository on it.
1) Log in to SourceForge
2) Go to Admin
3) Click on Tools
4) Click on Git. At this point, it will ask for Label and mount point for it. Enter those information. Once you finish it should create a new tab on top menu with whatever label name you provided. Let's say you named it 'Code' for now.
5) Click on 'Code' label and it would show you following instruction to push the code.
// First time using Git
cd <your_local_project_dir>
git init
git commit -a -m 'Initial commit'
git remote add origin ssh://<your_sourceforge_username>#git.code.sf.net/p/<your_project_name_on_sourceforge>/<mount_point_name_you_provide_in_step4>
git push origin master
// Existing Repository
cd <your_local_project_dir>
git remote add origin ssh://<your_sourceforge_username>#git.code.sf.net/p/<your_project_name_on_sourceforge>/<mount_point_name_you_provide_in_step4>
git push origin master
I think you might want to take a look at NetBeans' Git support;
http://netbeans.org/kb/docs/ide/git.html#initialize
It's built into the IDE so there's no plugin to install.

Eclipse/Egit, Push to Remote menu choice is grayed out

I created a repository on GitHub. I set up a local git repository using Eclipse and Egit.
With Team > Remote > Push. I managed to push the local repo to the one on GitHub.
Now I expected to be able to use the Team > Push to Upstream (as well as fetch from upstream) as a one-click push (and pull/fetch), but this menu choice is not available (grayed out). I have to use Team > Remote > Push to each time manually fill in the info (ctrl+space helps).
Following this, I created a remote configuration and pushed from the repositories view, and I can see the remote GitHub repository listed under Remotes but still the Team > Push to Upstream command is grayed out in the menu.
Could someone please give me a hint as to what I have may done wrong?
Here's what I did and this worked fine:
Right click your project, choose Team→Show in Repositories View. You will switch perspectives and be in the Git Repositories tab.
Right-click "Remotes" and choose "Create Remote". For "Remote name", enter "origin". Click OK.
Click Change. Enter your information as you did during your initial push. Click Save.
You should now be able to push by merely right-clicking on your project, then Team→Push to Upstream.
Because the remote was added under the project in question, each project can have its own upstream origin and they will not interfere (whereas the Window > Preferences solution is a global setting).
Based on your description of what you did, it appears you attempted this - but possibly did not use the name "origin" for the remote, which is absolutely necessary. I stumbled across this solution by pure chance.
I had this problem and thankfully found a way to re-enable the "Push to Upstream" option.
Go to Window > Preferences > Team > Git > Configuration.
Select the Repository Settings tab and then the repository that represents your project.
Click "New Entry..."
The key is remote.origin.url
The value is the url you copy from github. It's usually offered predominantly on whichever site you register with.
Perhaps there is a neater way of achieving the same thing. Once I reached this far I stopped looking because it works now.
You need to have the following type of configuration in that repository's .git/config file:
[branch "master"]
remote = origin
The remote setting can be any of your remotes or just a value of .
You can edit the repository's config by selecting the Properties menu item from the context menu for the repository in the Git Repositories view.
I came here searching for solution to solve similar problem with bitbucket - although none of the two highest votes answer didn't work for me, it proved that I had option "Put branch...", when I tried to do this, it says "Non fast-forward", but when I successfully made "pull", I was able to push to upstream.
Maybe it will help someone :)
This post might be a little old, but I had the same issue with one of my repos the following information from this link worked for me: Adding a remote to an existing git repo
The part i want to highlight from that article is the following:
[branch "master"]
remote = origin
merge = refs/heads/master
When I made the change in the .git/config and refreshed eclipse the "push to upstream" link worked for me. Keep in mind, I am assuming that you have a remote configured in your Git perspective for your remote repository.
In my case all git commit/push operations are inactive. I fixed the issue by placing the repository folder under git directory.

How can I add current Eclipse project to git with EGit?

I have GAE project in my Eclipse and I want to add it to my local git repo, how can I do that?
Since creating a Git repo within a GAE project is possible through command line, it is possible through Egit:
Follow that Egit tutorial:
For a new repo:
Right click your project, select Team -> Share -> Git.
Select the proposed line and press "Create repository". Press finish
Create the file ".gitignore" in your project with the following content.
All files / directories which apply to the pattern described in this file will be ignored
But you can also add it to an existing local repo by:
making a special branch for your project in your local repo (with just the .gitignore file in it)
clone it where your current project is
add all your current project files in it
import said Git repo into your workspace: See 4.2 Clone existing project.
informatik01 adds in the comment a link to a short article describing how to do it using the command line:
Adding Eclipse Project to Git
cd ~/workspace/my-project
git init .