I have a git repot that has a submodule.
I want to clone this repo into an eclipse workspace, I've read this
Working with Submodules
You can read more about what Git submodules are and how they work in this Git Community Book chapter.
Cloning Repositories with Submodules
Submodules are repositories nested inside a parent repository.
Therefore when doing a clone of a parent repository it is necessary to
clone the submodule repositories so that the files/folders are
available in the parent repository's working directory.
Checking the Clone Submodules button from the Git Clone wizard will clone all submodule repositories after the clone of the parent
repository finishes.
However, when I am done cloning, the submodule directory is empty
and the project doesnt appear in the workspace.
How do I add the submodule ?
in eclipse go to git explorer perspective
you can import you project modules under you project
project> working directory > select sub module > import project.
>> Import as general project (for new)
>> Import existing project (which will replace you current project)
if you have 3 modules you need to import one by one. as existing module or new one
git clone yourProjectUrl.
in your project folder: git submodule init (only do it first time)
you can also update submodule: git submodule update.
Related
I've GitHub repository in my IIB10 toolkit using EGit plugin.
I used to work with that repository.
I took workspace project interchange(PI) backup, later some changes my project has crashed.
So, I just imported my project from the PI backup and it got disconnected from GitHub.
I am using the same project in the different workspace, there also this project has deleted.
Now I have that project in the local workspace(not local git). How can I resolve this one? Please help me out.
If your workspace has no .git subfolder, you should at least:
clone your original GitHub repository
import your restored backup back to the new local clone
That is:
cd /path/to/restored/repo
cd ..
git clone https://github.com/<me>/<myrepo>
cd myrepo
git --work-tree=../repo add .
git commit -m "import from backup"
git push
How to import a specific project from github ? I dont want to clone the entire repository
I just want to clone only a portion of repository .
For eg this url https://github.com/eugenp/tutorials
has many projects but I just want to clone only spring-boot-crud project .
Here is the url for spring-boot-crud project.
https://github.com/eugenp/tutorials/tree/master/spring-boot-modules/spring-boot-crud
Thank you .
You can look into a git sparse-checkout: that command is made to checkout only part of a Git repository. This assume the latest Git 2.26 though.
And I mean Git-core, as in Git SCM, not Egit (which does not support the new sparse-checkout command)
Even though the command is new and still experimental, it should be useful in your case.
git clone --no-checkout /url/a/repo
cd repo
git sparse-checkout init --cone
git sparse-checkout set spring-boot-modules/spring-boot-crud
Then open the relevant project in your Eclipse.
Create a project in the Git repo (.project, in the root folder of your repo)
That will give you:
git clone -n https://github/git/git git2
cd git2
git sparse-checkout init
git sparse-checkout set Documentation
At this point, you have the repository git/git with only the folder Documentation checked out (everything else is not in the working tree)
# create an empty project in C:\path\to\git2 in Eclipse
As you can see, all the other files not checked out are not displayed in the Git staging view. Only the ones currently checked out and modified are listed.
The first step must be done in command-line because JGit does not support the sparse-checkout directive (see but 383772 and change 33)
We have a GitHub repository. After I clone that repository I have to do a git init from command line before any Git commands will work. git pull, git checkout, etc. don't work.
As far as I know, git init initializes a new repository. Is it like after cloning I am creating a new repository again?
Here are the commands I'm trying to run:
git clone <url>
git checkout master
You don't have to do git init in this situation¹. As pointed out in the comments, git clone will give you a local repository that you can start using right away.
The problem is that you're not in your repository when you try to run Git commands. By default, git clone puts the repository in a subdirectory with the same name as the repository that was cloned. You must change into that directory to use it:
git clone git#github.com/foo/bar.git
cd bar
Now that you're in bar/ you can interact with your repository.
¹If you do run git init in the parent directory you're in for a confusing time. You'll end up with a repository in the wrong place and an inner repository containing your code. Git's behaviour with nested repositories often doesn't match users' expectations.
After the clone, get into the projects root directory by `cd your-project" then run git commands
In your case what happened was, you cloned the remote repository then didn't change your present working directory to the cloned project, you were in the parent of the cloned repo, since parent repo itself is not a git repository, git complained, you can't run any git commands
I have a spring application in ClearCase repo currently with 3 folders architecture such as util, web and EAR but I need to migrate it to Git.
So how this architecture to be maintained with gradle, as I don't want to change my code
If your current working tree is working with graddle, simply import it in a new git repo from your snapshot view:
cd /path/to/snapshot/view
git init .
touch .gitignore
Add the files/folder you don't need in a git repo.
See for instance Gradle.gitignore
git add .
git commit -m "My first commit"
That won't import the full history (you still can see it through ClearCase), but you will then be able to push that git repo to a remote one, and start working with Git from there.
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