initialize bitbucket repository with existing project using netbeans - netbeans

I have an existing netbeansproject (about 20 classes, java) which i want to manage using a private repository. So I choosed bitbucket (have an acount and repository). I initialised a local git repository (using netbeans).
How can i connect my project with the bitbucket repository using netbeans?
When i try to "push" it i get this error message "Cannot connect to the remote repository at https://OsmosisDJones#bitbucket.org/OsmosisDJones/inba.git"

This is an old question, still if anyone needs the answer.
git add --all
git commit -m "Initial Commit"
git remote add origin https://...
git push -u origin master
You can find this info on bitbucket after you create the repository.

Related

In Eclipse java project, change git repository from an old one to a new one

I have a project in Eclipse that is associated with an old repository in Gitlab. The branch being used is called Test.
I created a new repository in Gitlab (and it only has the README.md file in it). It only has one branch: master.
I need to change the Eclipse project so that it no longer refers to the old repository (and old branch) but instead - refers to the new repository (with he master branch).
How can this be done?
TIA
Update
#Rizwan - thanks for the info. I did the following:
cd to the directory with the code
#initialize the repository
git init
#add reference to the repository I needed
git remote add origin "git#myrepo.com:WORK/<my-repository>.git"
#got what was currently in the repository
git pull origin master
#added code (not in the repository)
git add -A
#commit the code
git commit -m "first commit with code"
#sent it up
git push origin master
There was another message I used as a base (but I cant find it now)
TIA
We can directly perform this operation in Eclipse itself.
Goto - CurrentProject(Right Click) -> Team -> Remote -> Configure push to upstream -> Change(URI)
This might help
Locate your project on your local computer. You can do this by running:
cd /path/to/repo
Then check and confirm a list of all of your existing remotes. To do this run this command:
git remote -v
Change the URL of the remote with the git remote set-url command:
git remote set-url origin gitlab#gitlab.mydomain:root/testproject.git
Check back with the step 2 whether your repo has changed
Refresh/Clean Build your Eclipse project

best way to export Eclipse project to GitHub

I need to export an Eclipse project to GitHub. I am using Eclipse-Mars with the eGit plugin. I have spent hours reading documentation, tutorials, and posts and see that there are basically two ways
Create an Eclipse project and a local Git repository. Commit to local repository. Create a repository on GitHub. Push the Eclipse project to the repository on GitHub. When I try this, I get the error "rejected non-fast-forward". I have no idea why. I did create a .gitignore on GitHub when I created the repository - is that causing a problem?
Create a repository on GitHub. In Eclipse, clone this repository and then add files. Commit to local repository, then push. This works, but I end up with a weird configuration on GitHub:
reponame/myprojname/src
when I would prefer the more normal
reponame/src
Which method is the correct way to proceed? Why do I get the push error in the first method, and why the strange folder layout in the second?
You first need to pull the github code into you local machine.
=> git remote add origin
=> git pull origin master
will automatically fetch and merge the github repo with your local copy. You may need to resolve some conflicts that could be generated due to 3-way merge.
After all this, you can use -
=> git push -u origin master
For the second Point,
If you want src/ directory directly under reponame/ on github, then you should execute git clone after creating the project in eclipse and git clone should be executed inside the myprojectname/ directory.
When you created the .gitignore file on GitHub, you created a commit in the repository that isn't in your local copy. You'll need to add the GitHub repo as a remote, pull the change, and then push your local changes:
git remote add origin <path to your repository>
git pull origin master
git push -u origin master

C9 created workspace before repository

I made the mistake of creating a workspace before a repository on C9.io.
As a result I do not have version control. Naturally, I want to use Git for my project before make any more changes. Everything I have tried has failed. I would rather not have to copy all the code I've made into a new work space with an already set up repository. So if anyone has any suggestions or answers to this problem, via Command line, GUI or anything else that would be wonderful.
cloud9 doesn't do any special magic when cloning from a git repository, and you can add a remote the standard way you would do locally:
git init initialize a git repository in the current folder
git add -a add everything (or what you want)
git commit -m "initial commit" commit
git remote add origin git#github.com:<me>/<repo>.git add your repo
git push origin HEAD:master push HEAD to master branch in the remote you just added

Cloning a github repo into an existing project?

I have a project in Eclipse that I want to put on github, so I went to github and created the repos for them, but I want to clone them right into the folder where the files are stored in my eclipse workspace. How can I do this?
EDIT: When I try it, the github app says it can't clone because the folder isn't empty.
EDIT 2: Will this work? Changing the name in eclipse to rename the project folder, then cloning the repo to the name I want, in the workspace, then renaming the eclipse project so they merge and I can commit the new files.
GitHub has a guide explaining how to put an existing project on GitHub.
You should not clone the repository, but add the GitHub repository as a remote to a local repository you create yourself.
Go to your project folder and initialize a local repository with git init
Add and commit all your project files to the local repository. (e.g. git add . and git commit -m "message")
Add the GitHub repository as a remote. git remote add origin *github repository URL* (Verify with git remote -v)
Push your project to GitHub with git push origin master.
If you already have committed files to the GitHub repository, it is still possible.
Initialize your local repository.
Add GitHub as the remote.
Pull from GitHub.
Add and commit your project.
Push you project to GitHub
First add the remote as follows
git remote add origin <GIT URL>
Then simply do the following (MAke sure to commit any of your local files)
git pull --allow-unrelated-histories

Eclipse pull project to develop on another machine

I have a private repository on github.com and I want to pull it down to another development machine so that I can work with it in Eclipse but I am not sure exactly how to do it.
Do I have to create a local repository first or would that be created when the repository is pulled?
If you use git with eclipse, I assume you use eGit.
If you do, you can simply open File -> Import... -> Git -> Projects from Git -> Clone URI and from there everything should be clear to you. If it is not, just ask again and I will elaborate.
It will create a local repository for you if you chose so (later in the dialog you can chose something like import exisiting projects which is what you want if you already pushed your project to github once).
First, let's get eclipse out of the way. It has nothing to do with pulling/pushing to a remote repository.
The primary purpose of creating a remote repository is code collaboration. You can work on your local and then push to it. Others can pull from the remote and see your changes.
The primary way code collaboration is done in github is using the same model. To create a local branch out of a remote repository, you need to clone the repository. Cloning the repository would create a local master branch (the default branch) that will track the changes you make to your local repository. The other branch to note is the origin/master which tracks the changes you make to the remote repo.
When you want to make changes to the remote, you would need to perform three main steps:
Clone the existing repository: git clone https://github.com/johndoe/foo.git: this will create a local repository with the default master branch. You will work in this branch and when you have made the changes...
Commit the changes: git commit -m "this is the comment to identify my commit later"
Push it to the remote: git push origin master: origin refers to the remote repository; when you have cloned from the remote it is automatically called origin
So basically, you just need to clone the remote repository if you already have the remote on github. You don't need to create it separately.
You can import the project you have cloned into eclipse and work with it accordingly, then commit and push the changes to the remote.
Hope that helps.