Search code examples
gitbitbucketgit-clonegit-commit

What to do after cloning repo from git


I am just a git starter, basically I clone a git repository and now I wanted to commit the changes that I made in a file. when I run the command git commit it says not a git repository,

So being a starter in git i just wanted to ask that do i need to run this command first - git init and then git commit? Or in between these some more steps to follow to commit the file?

I need to commit files on Bitbucket.

Screenshot-

enter image description here


Solution

  • As jeremyharris said, the git documentation site and especially the online book there will get you up to speed on the basics.

    A few quick notes that might get you past your initial issue.

    git clone command is used to pull a copy (a clone) from an existing git repository. By default it creates a folder in the folder you execute it from that has a .git folder in it. The folder the cloning creates is your working copy and the .git folder is your local copy of the repository.

    git clone is different than most other git commands. All (or most?) other git commands require the command to be executed within the working copy folder created by the clone. (Bare repositories are a bit different since they don't have working copies, but that shouldn't apply here.) So, after doing:

    $ git clone <remote repo> <repo name> 
    

    do:

    $ cd <repo name>
    

    to get into the working copy before executing any other commands. Executing commands outside of the working folder will get you the not a git repository message.

    After making a change to a file, git add <filename> adds it to the index (marked to indicate ready to commit) and git commit -m '<commit message>' will then commit the changes.