So I am working on a java, spring and maven based project and I have a remote repository where I want to export it. As one can only export the .git projects in git repos, I have no idea how to create them and export the entire folder in the remote repository. Kindly let me know. Thank you for your time. If I have framed the question improperly, just let me know.
You can do git init --bare on the target server.
Then do git remote add <name> <endpoint> in the client project.
Last but not least: git push <name> <branch>
UPDATE
SSH is excellent for doing this :)
Suppose your project is called "test", do this:
ssh remoteserver
cd /path/to/projects
mkdir test # make a new directory for your project
cd test
git init --bare # creates the git server repo
On your client
git remote add origin ssh://user#host/path/to/projects/test
git push origin master
There are many different tools to assist you in committing and pushing your project into GIT. If you are using an IDE, it probably has a GIT tool as part of its VCS library. Check out your IDE’s documentation.
If you want to do it from the command line, make sure you have GIT in your path. Then go to your project fold and run the add, commit, and push.
git add –all
git commit -am "<commit message>"
git push
Related
I am new to git, I have many versions of a project stored in my local computer I wish to do the following
create a local repository in git from these versions with differently named root directory
see the differences between the versions
pl. help
Create a new directory, henceforth x, and cd x. Then run git init. This will start a new empty git repository inside the x directory. A git repository is a folder that has a .git subdirectory.
Copy the files from the first version of your project, paste them inside x.
Create a .gitignore file inside x and tell it which files of the project you do not wish be tracked by git. See here for more info.
After you're done, run git add -A to tell git to track all the files in the directory and prepare them for committing (this will add all files except for the ones mentioned in .gitignore).
Now run git commit -m "This is the first version of my project"
Now for the second version - completely overwrite all the files inside x with the files of the second version (by deleting everything except for .gitignore and .git and pasting the files of the second version). Then performs the commands similar to before:
git add -A
git commit -m "Second version of my project".
Repeat these steps for all versions - overwrite files, git add, git commit, repeat.
You now have a local git repository, with each commit corresponding to a version of your Java project.
You can see the differences between the versions using the git diff command or a Git GUI tool of your choice tool which allow you to explore your newly created repository.
You can now also upload your repository to a Git hosting service of your choice (popular ones being Github, BitBucket, GitLab and more) by creating an empty repository inside those services and adding it as a remote in your local repository and pushing the master branch (thus syncing the local copy of the repository with the remote host).
Note that this could be automated if you have a lot of versions, but such automation would largely depend on how your current "folder versioning" is structured, so this is up to you.
There are several examples on StackOverflow and on the web for creating a repository on GitHub and dowloading the repository into Eclipse. Most of these examples are very basic and very old.
I am looking for an up to date and clear step by step example that shows how to upload an existing Maven project from Eclipse to GitHub. The instructions here fail every time.
I thought this would be really easy to do. It has been two hours of frustration. Is there a more elegant solution out there than GitHub?
I would just handle it as it was a normal folder you want to push to GitHub.
So what you basically do is just what Github says if you create a new repo:
Navigate the bash into your folder, then...
git init
git add -A
git commit -m "first commit"
git remote add origin YOUR_GIT_REPO_LINK
git push -u origin master
I think this is the easiest way to do it.
I have modified the instructions found here that kept failing for me.
Go to github create new empty repository
Copy the https URL from github
Go to Eclipse --> Right click on project --> Team--> share project-->
Create new Git Repo.
Go to Git Staging--> Stage all changes --> "Commit" (do not "Commit and Push")
Right click on your Git Repository, select "Push Branch Master"
Paste your https URL of githun which you copy in step 2
I want to create a new Maven project in Eclipse and push it to a new repository on github. I am a bit stuck on the right order of steps to achieve this.
To use a Maven archetype, I cannot use a directory with files in it. So I cannot create a Maven project in a git local repository. So using the archetype should probably come first.
I also need to create a repository in my github account. If I do this through the github desktop app, this already creates a local repository for me.
Now I have an Eclipse project and a local repository, up to now unrelated. How should I "relate" them?
I found a lot of information about cloning from github, but my github repository does not have a Maven project yet, so I cannot import in Eclipse. If I use command line instead and an empty directory, I cannot apply Maven archetypes any more because the directory is not empty.
I am confused. Can somebody de-confuse me?
Create a new Maven project (however you want to create it). This, of course, will create a new directory in the file system with all the resources.
Create a repository in Github.
From the command line (located inside the project directory) do git init. This will create the local repository inside that directory.
Next, add a remote to your local repository: $ git remote add origin https://github.com/user/repo.git (optionally replace origin for the name your remote repository is going to be called, also replace user for your github username and repo for the name of your github repository name)
Add all files to be commited in the local repository.
For example
$ git add .
# Adds the file to your local repository and stages it for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.
Commit changes.
For example:
$ git commit -m "Add existing file"
# Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
Push to remote.
Just be clear, taking the following structure as reference, What I propose is to have as git repositories any of the directories project1, project2, projectN, not the whole worspace (/roo_dir/workspace/ directory).
/roo_dir/workspace/
- project1
- project2
- projectN
Additional readings:
Considerations for Git Repositories to be used in Eclipse
Should I store git repository in Home or Eclipse Workspace?
Is it better to keep Git repository inside or outside of Eclipse workspace?
Try this
Create a blank project in git hub
create a maven project in local
clone the git repo
this will not have any file
copy the maven project
add the files to git and push
Finally, I did the following:
I created a new Maven project with an archetype in the directory for github local repositories.
I used the github app to create repository with the same name in the same directory.
Then I published this repository to github.
Now I imported the project from the github local repository to eclipse.
The workflow is generally the one suggested by #lealceldeiro, but without using the command line git.
I have checked out the source from a git repo, because i was forced to use someone elses svn repo for a while, and now i want to re-check in my source in the original git repo. We are using eclipse (STS) for the project. The perfect solution would be to check in the changes made during this time into a new branch and then putting back together everything.
Does anyone know how I can do this?
If you have your changes made in one folder, you can use that folder as a working tree in order for your git repo to detect and add those changes.
cd /path/to/git/repo
git --work-tree=/path/to/other/repo status
git --work-tree=/path/to/other/repo add .
Then you can commit and push normally from your git repo now updated with the latest changes from the other repo.
Note: that is a command-line solution: once done, you can resume working in Eclipse.
I've imported a project from Git in Eclipse using this method:
File > Import > Git > Projects from Git > Next > Clone URL .
At this point I inserted the URI like this https://github.com/mygituser/My-Project .
Then my user and password, and the project was imported.
The problem is that Eclipse didn't recognize it as a Java project, and I really don't know why.
As consequence, I can't see errors or warnings on my project and neither use autocomplete, I'm getting this message "This compilation unit is not on the build path of a Java project".
Also, right click on My-Project > Build path shows the message "No actions avaliable".
If you need more information to help me, could you ask me on comments, please?
I appreciate your attention!
Most people don't include build files in repositories, only source. What you need to do is create a new Eclipse project the create a Git repo on top of that:
Create a new Eclipse project, and go to it with your terminal.
git init to initialize a repo.
git remote add origin https://github.com/mygituser/My-Project to add the remote.
git pull -u origin master to pull the changes.
Also, make sure that when you commit, you don't add build files that the author kept out. You can do this via a .gitignore file. Simply take this file and add it to your project directory.
This method applies to most Git repositories, as build and compiled files are usually left out.
Note that this method requires that you install Git for command line (or Git Bash). You can get Git at their website.
Since you already have the source code downloaded from the git repository, you should be able to create an Eclipse project from the existing source code.