7

I cloned a git repo into my pc using this command in my git bash

git clone https://github.com/xxx/yyy.git

which created a folder called yyy in my pc.

How can I update the folder yyy in my pc with new contents of the https://github.com/xxx/yyy.git (is it called remote repo)?

I followed the instructions in Updating a local repository with changes from a Github repository, in particular git pull origin master but none of them worked and returned the error $ git pull origin master fatal: Not a git repository (or any of the parent directories): .git.

I also tried git pull https://github.com/xxx/yyy.git as I reasoned that if I successfully did git clone https://github.com/xxx/yyy.git, the git pull https://github.com/xxx/yyy.git must work otherwise git syntax is not great.

Should I do the "clone" again to overwrite the existing folder in my pc? Why can't I do "pull"?

2
  • 1
    What is the error with git pull? Commented Mar 18, 2019 at 8:12
  • Hi Anurag. I've just updated the question with error message.
    – Nemo
    Commented Mar 18, 2019 at 8:16

2 Answers 2

14

You need to issue git commands from within the cloned repository:

cd yyy
git pull
3
  • can we do this without cd ?
    – Kalib Zen
    Commented Dec 27, 2022 at 2:01
  • 1
    Yes. Since git 1.8.5 you can do git -C yyy pull from the directory you were in when you performed the clone
    – mc1arke
    Commented Jan 3, 2023 at 8:07
  • and i think that should be the best answer ?
    – MaXi32
    Commented Jan 4, 2023 at 14:32
3

You are probably executing this command from outside the yyy folder. You have to go into it first:

cd yyy
git pull
6
  • Oh, I see. I did change the default directory of git bash to the folder zzz where it contains yyy because that what I did (cd zzz) when I did git clone ..... It WORKS! Thankyou. But why do I have to change it to yyy instead of zzz?
    – Nemo
    Commented Mar 18, 2019 at 8:25
  • Because you can clone multiple git repo's. If it would work from outside the folder, git would have no way to know which repo to pull in.
    – Sam
    Commented Mar 18, 2019 at 8:26
  • Could you please elaborate what you meant by multiple git repo's? Do you mean another repo like github.com/aaa/bbb.git? or github.com/xxx/yyy.git?
    – Nemo
    Commented Mar 18, 2019 at 8:28
  • 1
    Yes, cloning both would result in 2 folders (bbb and yyy). You can then choose which folder to work in by going into the folder with cd bbb or cd yyy. From there you need to execute all your git commands like git pull, git commit, ...
    – Sam
    Commented Mar 18, 2019 at 8:30
  • 1
    It looks like you made changes to your folder. You can git add . to track all changes you just made and then git commit -m "a message" to commit those changes. You can also git status to see which files you have changed.
    – Sam
    Commented Mar 18, 2019 at 10:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.