0

The project was developed on the local computer then the git push command send the changes to github. After that, the git clone command project was deployed to the server. Everything worked. Now I made new changes on the local computer, copied them to gitgub and I want to send them to the production server. Again doing

git clone https://github.com/myaccount/site

And I get an error

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

Which command should I use?

UPD

After git pull I got error

error: Your local changes to the following files would be overwritten by merge:
    album/api/serializers.py
    album/api/urls.py
    album/api/views.py
    customuser/models.py
    entertainment/forms.py
    places/models.py
    places/urls.py
    places/views.py
    templates/places/places_list.html
    templates/vtv/video.html
    vtoday/settings/base.py
    vtoday/urls.py
    vtv/models.py
    vtv/urls.py
    vtv/views.py
Please commit your changes or stash them before you merge.
error: The following untracked working tree files would be overwritten by merge:
    entertainment/migrations/0012_remove_entertainment_main_photo.py
    media/places/pexels-photo-373965.jpeg
    places/api/__init__.py
    places/api/serializers.py
    places/api/urls.py
    places/api/views.py
    places/filters.py
Please move or remove them before you merge.
Aborting
Jekson
  • 2,892
  • 8
  • 44
  • 79

2 Answers2

1

The error message is self explanatory, you are trying to clone a repository into a non-empty directory.

Nevertheless, to retrieve the changes you need to use the pull command, you don't need to clone the repository again, also, you need to commit your existing changes first so you can merge them with those you will pull from the server:

git add . --all
git commit -m "Add a description"
git pull

If you don't have any conflict your files will be merged automatically.

Then push everything to your remote server:

git push

See this question for other options: How do I resolve git saying "Commit your changes or stash them before you can merge"?

Edit

You have a merging problem:

Auto-merging entertainment/migrations/0012_remove_entertainment_main_photo.py CONFLICT (add/add): Merge conflict in entertainment/migrations/0012_remove_entertainment_main_photo.py Automatic merge failed; fix conflicts and then commit the result

It means that both repositories have modified the same parts of the file 0012_remove_entertainment_main_photo.py

If you just want to keep the file in the server just issue this command:

git reset entertainment/migrations/0012_remove_entertainment_main_photo.py

This will remove any changes you made to this file in your local repository

If you want to merge the files manually, take a look at this question How to resolve merge conflicts in Git?

Isma
  • 14,604
  • 5
  • 37
  • 51
  • Auto-merging entertainment/migrations/0012_remove_entertainment_main_photo.py CONFLICT (add/add): Merge conflict in entertainment/migrations/0012_remove_entertainment_main_photo.py Automatic merge failed; fix conflicts and then commit the result. – Jekson May 09 '18 at 10:42
1

To get changes from your Remote (in your case github) you should use git pull. Another option is described here Cloning is just done once per repo copy.

Further: If files are changed on your remote and on your local file system this leads to a conflict. If you want to keep your local changes without commiting them you can use:

git stash
git pull
git stash pop

If you want to commit you current changes just do it like:

git commit --all -m "My Message"
git pull

In case you just want to throw your local changes away just use:

git reset --hard

But there could be untracked changes (files which are not in your repo at the moment) which can be deleted by:

git clean -fd 

If possible git will auto merge those changes but it can lead to a manual merge which means you have to tell git which "version" you want to keep.

Jan
  • 1,004
  • 6
  • 23