gitgithub

On Branch master git status is showing nothing to commit (create/copy files and use "git add" to track)


I would like to commit but, whenever I am entering git commit -a -m "Initial commit. Added a gitignore file and a README file.

Git status showing as Nothing to commit ((create/copy files and use "git add" to track)

Git init
git add .
git commit -----------------

Where am I lacking? Thanks in advance.


Solution

  • nothing to commit (create/copy files and use "git add" to track)
    

    That means you are in a brand new local repo, with no file in it.
    You need to add files in that folder first, then you can add and commit.

    The full sequence would be:

    git init mynewrepo
    cd mynewrepo
    git remote add origin https://github.com/<user>/mynewrepo
    # write files (README, LICENCE, ...)
    git add .
    git commit -m "work"
    git push -u origin master
    

    Note that, as an alternative, you can create a new repository on GitHub side, directly with a README.

    Once that is done, you can clone it:

    git clone https://github.com/<user>/mynewrepo
    cd mynewrepo
    # add other files
    git add .
    git commit -m "work"
    git push -u origin master