1

I am new to git so sorry if the question is dumb.

I have a project called helloworld a branch called newfeatures which is not origin on github. My goal is to get all the files and folders into the folder in Eclipse directory I have specified we can call it /documents/eclipse/java.

What I did was that I install git then went into the development directory and typed

git init

git clone https://githuburlhere

I now have a folder called helloworld with a bunch of git-files but I don't see any java files from gihub. How can I get the files?

I have also tried

git pull origin newfeatures

But it said

fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

Clone
  • 3,378
  • 11
  • 25
  • 41
  • 1
    a bunch of Git files? Do you mean the hidden folder `.git`? Can you see the files in Github? – Raptor Jun 10 '22 at 01:19
  • @Raptor, yes its `README.md` and `.git` with the latter having a bunch of folders like branches, hooks, info, logs, objects, refs and files like config, description, HEAD, index, packed-refs – Clone Jun 10 '22 at 01:20
  • To clone a specific branch, read [this](https://stackoverflow.com/a/1911126/188331) – Raptor Jun 10 '22 at 01:22
  • Does this answer your question? [How do I clone a specific Git branch?](https://stackoverflow.com/questions/1911109/how-do-i-clone-a-specific-git-branch) – Raptor Jun 10 '22 at 01:22
  • So I tried it and it says: "fatal: destination path `helloworld` already exists and is not an empty directory." – Clone Jun 10 '22 at 01:24
  • WHat I typed was `git clone --single-branch --branch newfeatures https://github.....` – Clone Jun 10 '22 at 01:25
  • 3
    `git init` is for when you want to make a new repo "here" (the current directory). `git clone` is for when you want to copy a repo from somewhere else to "here" (a subfolder in the current directory). Pick one or the other, but not both. Note I may have misunderstood the question, and if I did, you likely want [one of the top answers to this question](https://stackoverflow.com/q/5377960/184546). – TTT Jun 10 '22 at 02:42
  • You should execute the command in an empty folder. Also, there is no need to use `git init` – Raptor Jun 10 '22 at 04:03

1 Answers1

0

Try:

cd /documents/eclipse/java
git clone https://github.com/me/myproject
cd myproject
git switch newfeatures

If newfeatures exists on the remote origin side, it will be checked out locally.

Make sure to point your Eclipse workspace to /documents/eclipse/java/myproject.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250