"git add" returning "fatal: outside repository" error

90,173

Solution 1

First in the clone folder you can create a Branch (so the master stay untouched)

git branch [branch_name]

After, just copy the files you want from your old folder to the clone folder.

When you are done, just add / commit your change and Merge your branch into the "master" branch. It will look like to something like this:

git add .
git commit -m "Comments"
git checkout master
git merge [new_branch]

Try this tutorial from GitHub.

Solution 2

You'll have to move all the files from /var/www/myapp to /home/mylogin/gitclone and then do a git add . and then git commit -m "Your message".

Solution 3

To add some files or folder to your repository, they have to be in the folder you created with git clone. So copy/paste your application in your local git folder and then go in it and do git add * and then you'll be able to commit to the server with git commit -m 'message' and finally push the changes to the server with git push

Solution 4

When upgraded to git version 2.12.2 that error appeared, I nooted the i add the file with a full path like:

git add c:\develop\project\file.text

when removed the full path it start working, like:

git add file.text

Solution 5

That's because you are versioning stuff inside /home/mylogin/gitclone and git tracks everything inside that folder. You cannot track other folders outside of this repository.

A solution might be create a submodule, or using a symbolic link using ln -s

Share:
90,173
dot
Author by

dot

Updated on February 18, 2021

Comments

  • dot
    dot about 3 years

    I'm just entering into the wonderful world of git. I have to submit a bunch of changes that I've made on my program, located in a directory called /var/www/myapp.

    I created a new directory /home/mylogin/gitclone. From this directory, I did a git clone against the public repo and I was able to get the latest copy created.

    I'm now trying to figure out how to take all the files in my working folder (/var/www/myapp) and "check them in" to the master repository.

    From /home/mylogin/gitclone, I tried git add /var/www/myapp but I'm getting an error that the folder I tried to add is outside the repository.

    Can you give me a few pointers on what I'm doing wrong? Also, I'd like to add everything, whether it's different from the master or not. Thanks.