What to do after cloning repo from git
Solution 1
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.
Solution 2
You need to add the change at first, use git add .
You can also check the status before adding, by using git status
EDIT
Just saw the comments about error. Yes that's correct. I neglect that.
Your problem is you need to cd
the git folder at first.
After that, you still need to add
as my answer above.
Trialcoder
From PHP -> Ruby on Rails -> NodeJS You can easily reach my mailbox at - [email protected]
Updated on July 11, 2022Comments
-
Trialcoder almost 2 years
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 saysnot 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 thengit commit
? Or in between these some more steps to follow to commit the file?I need to commit files on Bitbucket.
Screenshot-
-
Nevik Rehnel over 11 yearsif git says
not a git repository
, it's obviously a problem of being in the wrong folder. -
Trialcoder over 11 years@BillyChan..so i dont need to run git init command? I can directly execute this add command ??
-
Trialcoder over 11 years@NevikRehnel I just created a folder and run git clone command in the directory ..nothing else..so does it means i need to run git init command in this directory first before executing this add command ?
-
Trialcoder over 11 years@BillyChan I just added my screenshot ..plz chk
-
Nevik Rehnel over 11 years@user1594368:
git clone
by default creates a subdirectory for the newly created clone (you would have seen that if you had just looked into your folder). You should probably read a tutorial for git that explains the basic steps :) -
David Culp over 11 yearsJust saw you screenshot,
cd wedding
beforegit add .
andgit commit
. -
Trialcoder over 11 years..thx I changed the directory and initialize git and then add and commit and iot works for me :)
-
Trialcoder over 11 yearsthx for the comments..plz add this line in your answer .for future reference :)
-
David Culp over 11 yearsyou should not need to
git init
on a folder that has been created by thegit clone
command.git init
is used to create a new repository from an ordinary folder, which creates the.git
folder. It doesn't hurt anything to run it again -- it just should not be needed. -
7stud over 9 years@Davis Culp, I edited your post to add in a missing '>' bracket, which was confusing me, and I thought I might as well throw in a couple of blank lines for good measure. Sorry for the intrusion.