ransh
ransh

Reputation: 1702

missing folder in repository after git add

I'm using folder containing Software Development Kit (SDK), and tried to back it up with git into another folder in my laptop which I use as a git remote. I used git add *. It seemed that all worked well, I received no error or warning. So then i cloned the remote into another folder, and tried to compile, but got an error saying that files are missing. It turned out that a folder is missing in git.

Any idea what I did wrong ?

cd /home/ubuntu/backup
mkdir yamit
cd yamit
git init
git add *
git commit -m "first backup"
git remote add yamit /home/ubuntu/backup/yamit.git
git push -u yamit master

Upvotes: 7

Views: 19421

Answers (3)

jlmurph
jlmurph

Reputation: 1090

Late to the party, but i ran into this same issue.. Turns out i'd created my current project, and pushed it to a repo after working on it for a few days. Somewhere around that time i must have forgotten to add the missing directory's file to the local directory which is pushed on to my GitHub profile. Manually adding the file to the directory fixed it for me which is what led me to this conclusion.

Might be another thing to look at that wasn't mentioned earlier!

(mind you I use Intellij, which manages the git system in the background, the CLI approach might not have this same issue).

Upvotes: 0

VonC
VonC

Reputation: 1323303

Whenever you have a missing resource after a git add, you can easily check if it is part of any .gitignore with a git check-ignore (git 1.8.4+):

git check-ignore -v path/to/missing/ressource

Simply modify the .gitignore by removing its line ignore the resource you need.

Then add and commit again.

If you don't want to modify the .gitignore file, then a

git add -f .
# or
git add -f path/to/missing/*

That can force those ignored resources to be added to the index anyway.

Upvotes: 13

ransh
ransh

Reputation: 1702

Ok. I've resolved this. Just needed to call add with force into repository.

git add * -f

Yet, I still don't unedrstand why Git decided to ignore the folder when trying without forcing ( it's non empty folder).

Thanks. Ran

Upvotes: 3

Related Questions