0

I have received code for a modified older version of ERPNext from a backup tarball, and I want to add this code into a local Git repository on my Ubuntu laptop so I can keep track of changes until my employer can host a remote repository. Assuming that the backup was already extracted in ~/backup/erpnext/, I am trying to set up my Git repository for an initial commit like this:

cd ~
mkdir erpnext
cd erpnext
cp -r ~/backup/erpnext/* ./
git init
git add *

This, I thought, should add all of the files and folders in the backup to the ~/erpnext directory and stage them all for an initial commit. However, just to make sure it all works as expected, I ran git status before making a commit and was greeted with this output:

On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

    new file:   app
    new file:   conf.py
    new file:   conf.pyc
    new file:   erpnext-backup.log
    new file:   erpnext-sch.log
    new file:   lib
    new file:   public/app
    new file:   public/app.html
    new file:   public/css/all-app.css
    new file:   public/css/all-web.css
    new file:   public/js/all-app.min.js
    new file:   public/js/all-web.min.js
    new file:   public/js/editor.min.js
    new file:   public/js/slickgrid.min.js
    new file:   public/lib
    new file:   scheduler.lock

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

    modified:   app (modified content, untracked content)
    modified:   lib (modified content, untracked content)

What took me by surprise was that app and lib (which are both folders) were marked as having modified contents and were not staged for committing. I tried running git add --force on *, app and lib, but it doesn't seem to change anything.

I don't want to commit my code and have these folders excluded from the repository. How do I fix this?

Knowledge Cube
  • 990
  • 12
  • 35
  • Are `app` and `lib` *folders* or are they *submodules*? – Edward Thomson Jun 25 '14 at 15:33
  • 2
    do the `app/` folder and the `lib/` folder by any chances contain a `.git/` directory? – umläute Jun 25 '14 at 15:34
  • @EdwardThomson They should just be folders, AFAIK. This is all one self-contained project, so I wouldn't expect there to be any [submodules](http://git-scm.com/book/en/Git-Tools-Submodules) within it. – Knowledge Cube Jun 25 '14 at 15:36
  • @umläute Now that I take a look at it in my file manager, yes, the `.git/` directory is present, as well as a `.gitignore`. Should these be removed? – Knowledge Cube Jun 25 '14 at 15:37

1 Answers1

2

remove any .git/ directories in those sub-folders. they might confuse git (see git submodules for more information).

(btw, you can leave any .gitignore files, as they will hopefully help ignoring temporary files specific to these folders).

here's a handy command to remove all .git directories in any subdirectory of ~/erpnext (but not ~/erpnext/.git):

 find ~/erpnext/ -depth -mindepth 2 -type d -name .git -exec rm -rf \{\} \;

alternatively, if your upstream project is already a git repository (with submodules), you might just want to keep the original history, by continuing to work on the original VCS:

cd ~
rm -rf erpnext
cp -r ~/backup/erpnext .
cd erpnext
git log
umläute
  • 28,885
  • 9
  • 68
  • 122
  • Thank you very much! By the ways, to anyone else reading this: I found [this question](http://stackoverflow.com/q/1294590/3775798) useful for getting rid of those `.git/` directories. – Knowledge Cube Jun 25 '14 at 16:19
  • 1
    i added a (slightly different) command to remove those directories to the answer. – umläute Jun 26 '14 at 07:50