I keep getting this error no matter how many new repositories and new Java projects I try to create and push? It's like that project is somehow stuck in the program?
Java project cloning same project over and over even if I am creating a new project?
I am not sure if it is ok to delete program and start over?
Related
I have a working Spring Boot application that I created in Eclipse that I wold like to put into a new Git repository.
Unfortunately, I cannot seem to do this using Eclipse (or any other Git tool).
I am using Eclipse v2019-06 (4.12.0) and the Spring Tool Suite (STS) v4.3.1
To illustrate the problem, I take the following steps:
I create the Spring Boot project using STS:
Click on "Create a Project"->"Spring Boot"->"Spring Starter Project"
Project name is GitProject
Nothing fancy in this project. Createed a HelloController class that returned some HTML. Ran a browser to test it and displayed a "greeting" web page.
Compile project
mvnw clean package
Successful compile. Ran and successfully displayed web page:
java -jar GitProject-0.0.1-SNAPSHOT.jar
The project is successful and the service works. Place project into Git
There are procedures described to create and push to new repositories. Based on procedures provided in Stack Overflow answers, perform the following:
Create the repository
git init
Make it bare
git init --bare
Create a basic README file for adding to the repository
echo Testing > README
Add and commit the README file
git add README
git commit -m "Initial Code"
Now put the project into the repository. Or at least, attempt to...
Create a project in a different folder, importing from the new repository
Click on "Import projects..."->"Projects from Git"
Clone the URI from the new repository, Only the master branch is available. Place the destination in the project folder. Because there is no existing project in the new repo, and since the IDE does not offer a way to successfully create a new Spring Boot project from a repo (I made several attempts to use the New Project Wizard to create an STS project when creating the repo. Every attempt led to different Exceptions being thrown while creating the project), select "Import as General Project" in the "Select a Wizard" dialog.
Go to the folder with the original GitProject project. Copy everything from that folder and paste it onto the new project
Edit the .gitignore file that gets included in the Spring Boot project. It is important to remove all references to the STS files except for the .sts4-cache file. These need to be saved at least once in order to ensure that the Spring Boot information is saved in the repository.
Right- click on the project and select Team->Commit
Stage everything, enter a commit message, then click on "Commit and Push"
See the following failure:
master-master [remote rejected]
Repository
branch is currently checked out
error: refusing to update checked out branch: refs/heads/master
error: By default, updating the current branch in a non-bare repository
is denied, because it will make the index and work tree inconsistent
with what you pushed, and will require 'git reset --hard' to match
the work tree to HEAD.
You can set the 'receive.denyCurrentBranch' configuration variable
to 'ignore' or 'warn' in the remote repository to allow pushing into
its current branch; however, this is not recommended unless you
arranged to update its work tree to match what you pushed in some
other way.
To squelch this message and still keep the default behaviour, set
'receive.denyCurrentBranch' configuration variable to 'refuse'.
What is strange is that somehow this branch remains "checked out" after being cloned but the IDE does not appear to provide a way to "check it back in". Worse: I actually tried just cloning the new repo, changing the README file, then committing and pushing it (without including the Spring Boot code) and that attempt yielded the same failure.
So how do I get this code committed and pushed into my repository? What step is missing from the documentation of how to do this???
I am new to Git and was exploring the Git integration in Eclipse, IntelliJ, and Pycharm. In Eclipse, the way projects get exported seems to be that the project gets added to an existing repo, while in IntelliJ and PyCharm, the project's root directory itself becomes a Git repo. This approach made the most sense to me, but then again I don't have much experience in sharing code. This latter approach is also possible in Eclipse by clicking the "Use or create repository in parent folder of project" checkbox, but when I did so, Eclipse told me that using the parent folder was not recommended.
Now for my question: Why does Eclipse warn against doing precisely what JetBrains IDE's do by default? What are the dangers in using a project's parent folder as a Git repo?
I read online that it has to do with the fact that once the parent folder is created as a repo, you can't add any new projects to the repo. But what are the benefits of adding projects to existing repos vs just making a separate repo for each project to keep everything separate?
I am pretty new to GitHub.
This is my problem: We (4 people) are working on a Java project. Two of us are using NetBeans and two of us are using Eclipse. Let`s say 1 person created a project from Eclipse and pushed the project into the repository. Now, I want to clone the repository and work on the project. I can successfully clone the project and I can see all the files that we have in the repository. However, I cannot run the project. In fact, when I am cloning the project, NetBeans asks me for creating a new project. I do not want to create a new project but I want to work on the same project that I am able to run it.
What is solution?
I recommend to commit the Eclipse project meta-files (.project, .classpath and may be the .settings directory) and the NetBeans project meta-files (I don't know the corresponding meta-file names for NetBeans).
From your problem description it seems the NetBeans project meta-files are missing in the github repository. Hence, NetBeans doesn't recognize the cloned repository as a project.
See also: Which NetBeans projects files should go into source control?.
We are trying to use Eclipse and github on a project, and it is proving to be a real burden because we do not understand how it works. It is difficult to formulate a single question, but let's start with one case:
We have a project in Eclipse that is on github. Several developers are sharing the archive. We learn that we want to create a Java EE project rather than a Java project. We do not want to change the name of the project. How can this be done?
Further, not knowing this, we tried to change the name from ProjNamet to ProjName2.
When creating a project on git, Eclipse creates it in a local directory:
c:/Users/username/git
In order to push that project out to github, we executed:
git remote add origin github.com/author/projname
git push origin master
As far as we can see, the project appears to be successfully pushed out to github.
In addition to source code, there is:
.project
.gitignore (which just ignores the build directory)
.classpath
.settings
But when I right click on the repository and try to import projects from it to my computer, Eclipse failed
deleting the directory, and clicking on File->import.. and importing from the repository works.
I do not see what the difference is between the one that worked and the one that did not.
Try this:
git remote add origin github.com/author/projname
git push origin master
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