Search code examples
gitfilepath

Why does git say that my file is outside the repository?


Hey guys beginner here how do I upload file into github using git.

This is my command:

$ git add C:\Users\Dan\Downloads\filecrdownload
fatal: C:UsersDa: 'C:UsersDan' is outside repository

What did do wrong? How should I fix this?


Solution

  • Assuming you already have a repo set up on Github, you'll need to clone it on your computer.

    git clone <url-to-repo>

    The url can be found on the front page for your repo:github repo url

    Clone will create a new directory in your filesystem, and you'll want to move your file into there.

    Once the file is inside your git directory, you can simply do:

    git add filecrdownload
    git commit -m "Added filecrdownload"
    git push
    

    Which stages filecrdownload, makes a new commit and pushes that commit. You should now see it on Github.