0

I am trying to learn git and created a local directory called local-repo with a couple of files. I then initialized git in this directory, added all the files to the staging area, and then committed them to the repository. Next, I cloned the repository in local-repo to another directory on my system called cloned-repo : git clone ./.git ../cloned-repo

Next, I made some changes to one of the files and attempted to push the files back to the repository in local repo but ran into the problem described here. Based on the first answer, I executed git config --bool core.bare true in local-repo and then deleted all the files in that folder except .git. This allowed me to successfully push the repository in cloned-repo to local-repo:

(base) sk@darwin:~/learn_git/cloned-repo$ git push origin master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 336 bytes | 336.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To /home/sk/learn_git/local-repo/./.git
   7ceaa95..8951be6  master -> master

However, I am unable to understand where the files actually are now, as local-repo still contains only the .git directory:

(base) sk@darwin:~/learn_git/cloned-repo$ cd ../local-repo/
(base) sk@darwin:~/learn_git/local-repo$ ls -al
total 12
drwxr-xr-x 3 sk sk 4096 Jun 17 19:36 .
drwxr-xr-x 4 sk sk 4096 Jun 17 18:28 ..
drwxr-xr-x 8 sk sk 4096 Jun 17 19:36 .git

Where the changed files actually pushed from cloned-repo to local-repo or is my understanding of the process incorrect?

Anonymouse
  • 147
  • 1
  • 8
  • `.git` is a directory. Your files are in there. https://www.siteground.com/tutorials/git/directory-structure/ – tkausl Jun 18 '20 at 00:03
  • https://git-scm.com/book/en/v2/Git-Internals-Git-Objects – matt Jun 18 '20 at 00:07
  • My mistake...I do realize that .git is a directory. Further, based on the information given in the second link, I could find display the contents of the files using the checksum hashes listed in .git/objects. However, is there a way that I can see the listing of the files in the usual directory structure? – Anonymouse Jun 18 '20 at 01:06
  • You mean https://git-scm.com/docs/git-ls-tree ? – matt Jun 18 '20 at 02:21
  • Not in a bear repo... you would have to use things like `git ls-tree -r some-branch` and then from object IDs get the content on that branch – eftshift0 Jun 18 '20 at 02:31
  • I was able to list the files using `git ls-files`.However, how do I now access the files, that is, open them and work on them? – Anonymouse Jun 18 '20 at 03:10

0 Answers0