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"?

Nemo
  • 1,124
  • 2
  • 16
  • 39

2 Answers2

14

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

cd yyy
git pull
mc1arke
  • 1,030
  • 10
  • 22
3

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

cd yyy
git pull
Sam
  • 5,375
  • 2
  • 45
  • 54
  • 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 Mar 18 '19 at 08: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 Mar 18 '19 at 08:26
  • Could you please elaborate what you meant by multiple git repo's? Do you mean another repo like https://github.com/aaa/bbb.git? or https://github.com/xxx/yyy.git? – Nemo Mar 18 '19 at 08: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 Mar 18 '19 at 08:30
  • Thankyou, Sam. Would you mind looking at this error I've just got it now when doing git pull ```Please commit your changes or stash them before you merge. Aborting Updating 5deedcc..9e2c1b4```. Is my local folder updated? How can I commit? – Nemo Mar 18 '19 at 08:33
  • 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 Mar 18 '19 at 10:04