'How to update a Github cloned repository?

I have created a repository on Github, and the cloned from my local machine and also push some code. I cloned that repository from a virtual online machine with the repository code, the problem is that I have already cloned it once, after that, I commited some changes from my local machine and tried to clone the repo online again to add that changes to my online repo, but I got this error:

fatal: destination path '' already exists and is not an empty directory.

I don't know if there's another way to acomplish this, I'm pretty new to git and there's a lot yet to learn.



Solution 1:[1]

Use git pull instead of using git clone a second time in your virtual machine. Make sure to cd into the repo folder on the virtual machine before you pull.

You only need to clone once. Every time after that you only need to pull new updates.

Solution 2:[2]

This error will show, when you try to clone a repo in a folder where a git repo already exist (.git-folder).

When you have git clone once your git repository, and you will update this repository, to be up to date on your local computer, you must do git pull to become the changes from the remote repository to your local computer.

Short explanation:

git clone - you download all files from this repository and the sourcetree from this repository

git pull - takes all changes from remote to your local computer

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TheIceBear
Solution 2