Search code examples
gitdirectorybranchclone

How to Change the current working Directory in Git?


When I am adding a new project to repository, I am getting this error.

Error - fatal: '/Users/username/Downloads/folder_name' is outside repository.

I think, I need to give the current working directory. But, don't know how to do that..Can anyone help me out of this? But when I add new file directly, it works fine.. Your help is highly appreciated..Thanks in advance.

I got everything fine..But if I refresh the page, it remains the same... https://github.com/dinesh-prodapt/myandroid.git

That's why confused.. Here is what I am getting..

Dinesh-iMac:~ dineshkumar$ git remote add origin [email protected]:dinesh-prodapt/myandroid.git
    fatal: remote origin already exists.
    Dinesh-iMac:~ dineshkumar$ git push -u origin master
    Counting objects: 3, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (2/2), 280 bytes | 0 bytes/s, done.
    Total 2 (delta 0), reused 0 (delta 0)
    To [email protected]:dinesh-prodapt/dinesh.git
       c6537f0..433adae  master -> master
    Branch master set up to track remote branch master from origin.
    Dinesh-iMac:~ dineshkumar$ git remote add origin [email protected]:dinesh-prodapt/myandroid.git
    fatal: remote origin already exists.
    Dinesh-iMac:~ dineshkumar$ git push -u origin master
    Branch master set up to track remote branch master from origin.
    Everything up-to-date

Solution

  • you cant add a file to git using git add that it outside of the folder.

    for example

    /Users/username/dir1   
    

    Contains the .git folder (ie the git root)

    you can only add folders and files below that

    such as

    /Users/username/dir1/images
    /Users/username/dir1/src
    /Users/username/dir1/dir2
    

    But not

    /Users/username/dir2
    /Users/username/Desktop 
    

    because they are outside of what git knows about

    you need to move the file (or copy) with the mv or cp commands to dir1 and then use git add

    to the second problem (which you should really create a new question for)

    git remote origin exists already so call it something else or remove your exiting origin

    git remote add github [email protected]:dinesh-prodapt/myandroid.git
    git push -u github master