Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 264
dot Avatar asked Feb 25 '13 16:02

dot


People also ask

How do I fix a fatal Not a git repository?

For the second situation, you need to initialize the Git repository in your project folder. To do so, you need to navigate to the correct folder and then run the command git init , which will create a new empty Git repository or reinitialize an existing one.

What is git add command?

The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit. However, git add doesn't really affect the repository in any significant way—changes are not actually recorded until you run git commit .

How do I add a file to Git?

To add and commit files to a Git repository Create your new files or edit existing files in your local project directory. Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.


3 Answers

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.

like image 141
JudgeProphet Avatar answered Sep 16 '22 19:09

JudgeProphet


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".

like image 25
Catfish Avatar answered Sep 16 '22 19:09

Catfish


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
like image 29
Pedro Lopes Avatar answered Sep 18 '22 19:09

Pedro Lopes