0

Okay im new to Git and it might be a noob question, but i don't quite understand how to access this project of a friend of mine.

Basically i wanted to take a look at his project and learn from it. He sent me a zip file, i unzipped it and imported the folder into intellij(with maven, as this standard in our uni). Now unlike other projects that I've seen so far, it didn't contain any packages or java files whatsoever. Only an empty git file, pom.xml a log file and few xml files in an .idea folder

Going back to the folder in my browser it also contains a .git folder, which as far as i understand is supposed to be a git repository. Contains folders such as hooks, info, logs, refs and objects (last one is 2mb big, further contains numbered folders with randomly named files of no type) How can i access/display the contents of this folder?

Now i've tried looking it up but my search always leads to "creating a new repository from an existing project" etc and not to what im looking for. I only understand how to clone a repository from an url, but not from a git folder itself.

Anyways is it possible for me to open this folder/repository, if so how? Any help or "how-to links" would be appreciated

Edit: If its not supposed to work like that and java files etc still have to be there and sth. went wrong on my friends end - let me know

Edit2: Project was made with eclipse - i also tried opening it with that program but made no difference

Gidar
  • 9
  • 3
  • What happens when you just unzip the file normally, no maven, no intellij. just your filemanager? – paulzmuda Jan 30 '19 at 04:18
  • Well thats what i did, unzip the file normally. then import the folder into intellij. The project folder is as described. Contains a .idea folder with xml files, .git folder , the usual iml, pom.xml. a log file , .gitignore – Gidar Jan 30 '19 at 04:25
  • what happens when you go into your terminal, go to the directory of the unzipped folder, and type `git branch` ? I'm thinking files are hidden in a different branch, otherwise you have an empty repo. You should be able to see the code files outright, if you don't they either don't exist or you need to checkout a different branch. I think you mentioned the file was 2mb big, if that's the case it's gotta be hiding some files. Are you expecting javascript files or what? – paulzmuda Jan 30 '19 at 04:30
  • Nothing special, just a simple program with some java classes. git branch does/shows nothing. Well ok if they are supposed to show up (like im used to) then i guess its empty as you said. Git/objects is just another folder that further contains folder like 00,0a,02...info and pack. And the numbered folders contain random files (like efec27ab120fef2998 for example) – Gidar Jan 30 '19 at 05:01

1 Answers1

0

You need to switch back to command line and check what git status reports.

A git checkout master -- would help forcing the files in the master branch to be checked out in your current working tree.

Note: a proper way to send a repo as one file is a git bundle.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • Thanks for the reply @VonC git status says following: On branch master No commits yet || Changes to be commited: new file: || Changes not staged for commit: deleted: || Message after git checkout master -- : fatal: reference is not a tree: refs/remotes/origin/master || I looked into git/refs and there are only 2 empty folders heads & tags. git checkout -b master switches to new branch 'master' but the fatal error msg doesnt change. Are the files gone for good or are they somewhere temporarily stored? – Gidar Jan 30 '19 at 07:44
  • @Gidar OK, try a `git reset --hard` – VonC Jan 30 '19 at 07:46
  • well git status now only lists the untracked files, and the added (to be comitted) files are gone. They don't show up in the folder as well – Gidar Jan 30 '19 at 07:49
  • Btw. i know the remote repositry adress now, but unfortunately it's long gone – Gidar Jan 30 '19 at 07:50
  • @Gidar And `git reset --hard origin/master`? – VonC Jan 30 '19 at 07:53
  • fatal: Could not parse object 'origin/master' ^^ what i forgot to mention was when i tried to commit earlier it also gave the error msg: Invalid object ... 'for src/main/java/randomfile' || error: Error building trees i suppose since its not there – Gidar Jan 30 '19 at 07:57
  • @Gidar OK `git reset --hard master` then – VonC Jan 30 '19 at 07:59
  • yeah i tried master or origin separatly but it only says: fatal: ambigous argument 'master' unknown revision or path not in the working tree. – Gidar Jan 30 '19 at 08:06
  • @Gidar What `git branch -avv` return? – VonC Jan 30 '19 at 08:27
  • nothing (before and after git reset --hard as well) – Gidar Jan 30 '19 at 08:32
  • @Gidar Oh, that is the problem. A full zip repo should have included branches. Any chances you can get a bundle (as I suggest in the answer) instead of the zip file? – VonC Jan 30 '19 at 08:33
  • @Gidar Do you have at least an history? (`git log --all --branches --oneline --graph ---decorate`) – VonC Jan 30 '19 at 08:34
  • sry, like i said i dont know much about git. All i did was git init and git status so far. I have no idea how to add branches etc that might be missing since most of the code has been apparently deleted. well i try to reach my friend again, but he told me before that that was all he had left. || "git log --all --branches --oneline --graph ---decorate" results into - error: refs/remotes/origin/master does not point to a valid object! fatal: unrecognized argument: ---decorate || same error msg without the --decorate – Gidar Jan 30 '19 at 08:45
  • @Gidar Wait... `git init`? You are not supposed to do a `git init` at all: just unzip the archive, go inside, and try git status. If the folder where you have unzipped the archive has itself a `.git`, you are good to go. – VonC Jan 30 '19 at 08:51
  • @Gidar And `decorate` is a valid option. I just mystype: `---decorate` (three `-`): the correct syntax is `--decorate` (two `-`) – VonC Jan 30 '19 at 08:52
  • if i don't use git init to reinitialize the repository ít tells me fatal: not a git repository (or any of the parent directories): .git – Gidar Jan 30 '19 at 08:58
  • @Gidar That is because you need to put this `.git` folder in an empty parent folder, and run your `git` commands in that parent folder. – VonC Jan 30 '19 at 09:07
  • doesn't work for me unfortunately, i tried it in an empty folder and the same msg appears – Gidar Jan 30 '19 at 09:28