Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing source files from git BARE:master

Tags:

git

I'm certain that I'm missing something fundamental here, but I've received a drop of an application stored in a git repository. It has folders like: branches, hooks, objects, etc, but no actual source files.

When I open up git bash and cd into that folder, the title says "(BARE:master)".

I assume I just need to somehow clone a local reposisitory from that folder. Ultimately, I just need access to the actual source files in the repository, but I'm surely missing some concept as I'm somewhat new to git.

Any hints or help on how I can get this set up locally would be appreciated.

edit: when I try to clone from that directory I receive the following error

$ git clone c:/Users/Joel/Dropbox/TheProjectDirectory.git
Cloning into LocalProjectFolder ...
fatal: 'c:/Users/Joel/Dropbox/TheProjectDirectory.git' does not appear to be a git
 repository

fatal: The remote end hung up unexpectedly
like image 263
Joel Martinez Avatar asked Jun 19 '11 17:06

Joel Martinez


People also ask

How do you clone from a bare repository?

In order to clone your repository to create a new bare repository, you run the clone command with the --bare option. By convention, bare repository directory names end with the suffix . git , like so: $ git clone --bare my_project my_project.

What is the point of a bare repository?

Repositories in Git are a snapshot of the folder in which you are working on your project. You can track the progress and changes made to the project by making commits and also revert changes if not satisfactory.


2 Answers

It is bare repository what you have.

The simplest way to get sources is to clone it via git clone /path/to/your/bare/rep

The bare repositories is something like shared repository, where work from several developers get gathered. For developer box you most probably want non-bare one.

There's a chapter about cloning repositories.

EDIT: So, I have some git repository on my box. So I'll try to emulate your situation. First I'll clone my repository as bare one:

idanilov@IDANILOV-PC /d/test
$ git clone --bare /d/work/gittesting/ bare.git
Cloning into bare repository bare.git...
done.

idanilov@IDANILOV-PC /d/test
$ cd bare.git/

idanilov@IDANILOV-PC /d/test/bare.git (BARE:master)

So here I have bare.git repository like you have your shared folder. Now I will clone it to have some working directory with actual sources:

idanilov@IDANILOV-PC /d/test/bare.git (BARE:master)
$ cd ..

idanilov@IDANILOV-PC /d/test
$ git clone bare.git/ my-non-bare-dev-rep
Cloning into my-non-bare-dev-rep...
done.

idanilov@IDANILOV-PC /d/test
$ cd my-non-bare-dev-rep/

idanilov@IDANILOV-PC /d/test/my-non-bare-dev-rep (master)

Now I have folder my-non-bare-dev-rep and all files from repository are there. It is you working copy. String (master) is the hint for you that you are in the master branch now.

Then I'll emulate some work in my working copy.

idanilov@IDANILOV-PC /d/test/my-non-bare-dev-rep (master)
$ echo 'my new text' > text-file.txt

I want to see changes I have in working copy comparing with the version I got from shared rep:

idanilov@IDANILOV-PC /d/test/my-non-bare-dev-rep (master)
$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       text-file.txt
nothing added to commit but untracked files present (use "git add" to track)

Now I will add this text file to so-called stage area (or sometimes it is called index). It is the term to describe a set of changes that will be committed when git commit command is executed.

idanilov@IDANILOV-PC /d/test/my-non-bare-dev-rep (master)
$ git add text-file.txt

Well now text-file.txt is in the stage area. But it is still not committed. It is time to do this:

idanilov@IDANILOV-PC /d/test/my-non-bare-dev-rep (master)
$ git commit -m 'my commit from dev repo'
[master c0b0bd8] my commit from dev repo
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 text-file.txt

So. Now it is stored in my local repository. In the .git folder actually. But it is still not went to shared repo so that my colleagues also see it. For this I need to do a push:

idanilov@IDANILOV-PC /d/test/my-non-bare-dev-rep (master)
$ git push origin
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 290 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To d:/test/bare.git/
   d01886b..c0b0bd8  master -> master

origin is a standard name git gives to parent when you did a clone. So as I did clone from bare.git - my changes just went there. And finally to get updates from shared folder into your local repository you have to execute pull command:

idanilov@IDANILOV-PC /d/test/my-non-bare-dev-rep (master)
$ git pull
Already up-to-date.

I don't have any changes pushed to bare.git from other places, so my local rep is up-to-date. And git told me so.

like image 69
Ivan Danilov Avatar answered Sep 21 '22 01:09

Ivan Danilov


Use

git clone /c/some/dir.git

In git bash. C: type paths are not handled well.

like image 26
Adam Dymitruk Avatar answered Sep 19 '22 01:09

Adam Dymitruk