Forums

git pull doesn't update files

Hi guys,

I am following Django Girls Tutorial, I am on html section - https://tutorial.djangogirls.org/en/html/ - where git is updated than files are transferred to pythonanywhere by using git pull. My git has been updated however, after git pull on pythonanywhere I do not see updated Files. I rerun my web app as well, no changes.

After git pull I see files changes, insertions and deletion, but no files updated in FILES section. I was trying to find how to solve this and looks like this issue was already raised few times, however without solution.

Thank for help, Bogdan

Are you sure you had already git pushed from your local to github before you did the git pull on PythonAnywhere?

Looks like I messed up with files, double created some files.... I removed web app, deleted all files and run git clone from github. Than manually configured web app as per https://www.youtube.com/watch?v=Y4c4ickks2A . Now everything is updated.

Regards, Bogdan

Hi,

Could either of you help me out? I am up the same step and when I try to run git pull into my PythonAnywhere bash console I receive this message

"5:19 ~/millyshelston.pythonanywhere.com (master)$ git pull
Updating 8f56bf0..9a5c8b4
error: Your local changes to the following files would be overwritten by merge:
        mysite/settings.py
Please, commit your changes or stash them before you can merge.
Aborting"

Then when I run git diff I receive this message

"5:21 ~/millyshelston.pythonanywhere.com (master)$ git diff
diff --git a/mysite/settings.py b/mysite/settings.py
index a24f0c4..9dfc96c 100644
--- a/mysite/settings.py
+++ b/mysite/settings.py
@@ -120,3 +120,8 @@ USE_TZ = True

 STATIC_URL = '/static/'
 STATIC_ROOT = os.path.join(BASE_DIR, 'static')
+
+MEDIA_URL = '/media/'
+STATIC_ROOT = os.path.join(BASE_DIR, 'static')
+MEDIA_ROOT = os.path.join(BASE_DIR, 'media')"

Do you know what I need to change in settings? And if I change it in python anywhere or on sublime?

Thank you - milly

[edit by admin: formatting]

What git is telling you there is that you've added some stuff to your settings.py on PythonAnywhere. This means that if you pull changes down from github, they'll get overwritten. So you have two options:

  • If the code you have on github is exactly what you want, and you want to throw away the changes on PythonAnywhere, you can tell git to do that with this command:

    git reset --hard
    

    That will leave you in a state where you don't have those changes, so git pull will be able to pull the changes down from github without errors. * If the code you want is a combination of the changes you've made on PythonAnywhere with the changes that are on github, you can commit the changes on PythonAnywhere, then pull down the changes from github. The command to commit the changes would be something like

    git commit -am"Updated MEDIA_URL, MEDIA_ROOT and STATIC_ROOT
    

    The bit in brackets is the commit comment, so you can put anything you want there. Now that the changes are committed, you can do a

    git pull
    

    Because you'll be merging changes from two different branches of your code (the one on PythonAnywhere and the one on github) it will probably present you with an editor with a merge comment in it -- the editor will be vim, which (if you're not familiar with it) is kind of hard to use. However, the comment that it will suggest will be an OK one, so all you need to do is save the file and exit vim -- and to do that, hit the escape key a couple of times, then type ":wq" then hit return.

    After doing all of that, you'll need to push the changes up from PythonAnywhere to github with a

    git push
    

    ...and then on your own machine, you'll need to pull them down with a

    git pull
    

for me it was:

I did the git add .

and the git commit

but I forgot the git push from my CPU.

So my pythonanywhere could not see updates, because I hadn't actually pushed them into github.

My cpu version is the one I want pulled onto my pythonanywhere account then in the pythonanywhere bash I could do this:

git fetch #grab updates from github

and then

git pull

Yup, that should do the trick! In fact, you could even skip the "git fetch", as "git pull" fetches anyway by default.

Hi, below you can see that only "git pull" doesn't update this "settings.py" file... it says "already up-to-date" but with "git status" you can see that the file is still "modified"... (and not updated) on pythonanywhere. What am I missing?

(antunes.pythonanywhere.com) 17:33 ~/antunes.pythonanywhere.com (master)$ git pull
Already up-to-date.
(antunes.pythonanywhere.com) 18:12 ~/antunes.pythonanywhere.com (master)$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
        modified:   mysite/settings.py

Oh sh*t, git!

@antunes

Your local repo is the same as remote one, but you have modified settings file in your working directory, not staged it and not commited. Your local repo and your working directory are two different things. Take a look at that

The same thing as mentioned by Bogdan was happening to me.

The way I fixed this was going to the "Web" section and clicking on "Reload". From there everything was fine.

Hi, This is my first trial for the pythonanywhere. It seems I am not the first one encounter this problem. The files did not updated after 24 hours since 'git pull' and 'reload' submitted.

I have commit and push my source code into Github repository. In PythonAnywhere bash console, I use 'git pull' to pull down the changes on my Github. The following messages shown in bash console seems like it is succeed.

(myproj) 09:52 ~/django-sample/learning_templates (main)$ git pull 
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 3), reused 6 (delta 3), pack-reused 0
Unpacking objects: 100% (6/6), 505 bytes | 5.00 KiB/s, done.
From https://github.com/nobodybutyoulin/django-sample
886b16d..23ea541  CN-0807-indexhtmlchange -> origin/CN-0807-indexhtmlchange
Already up to date.

After reload the application in the Web tab, I still can not see the code changed for the supposed to be updated files in the Files tab. The file date remains no change after 'git pull' as follows: index.html 2021-08-04 13:01 184 bytes

Thanks, Robert Lin

hi, seems we are talking over email as well. I will try to post our replies here so that everyone else can also benefit.

Finally, found out the reason why the "git pull" does not update my files on pythonwhere. Maybe I have tuned some setting in the setting.py file on my pythonanywhere repository, as a production site, after git clone from my github repository. But the changes did not sync with github through commit and push using pythonanywhere console. I found this issue through "git status" and this issue has been resolved by submit the "git stash" ("git restore" can also be used to discard changes in the working directory) and "git merge". So, thanks it works now. The result of the "git status" on pythonanywhere console as follows:


(myproj) 09:01 ~/django-sample/learning_templates (main)$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
    modified:   db.sqlite3
    modified:   learning_templates/settings.py

Untracked files:
(use "git add <file>..." to include in what will be committed)
    basic_app/__pycache__/__init__.cpython-39.pyc
    basic_app/__pycache__/admin.cpython-39.pyc
    basic_app/__pycache__/apps.cpython-39.pyc
    basic_app/__pycache__/models.cpython-39.pyc
    basic_app/__pycache__/urls.cpython-39.pyc
    basic_app/__pycache__/views.cpython-39.pyc
    basic_app/migrations/__pycache__/__init__.cpython-39.pyc
    learning_templates/__pycache__/__init__.cpython-39.pyc
    learning_templates/__pycache__/settings.cpython-39.pyc
    learning_templates/__pycache__/urls.cpython-39.pyc

no changes added to commit (use "git add" and/or "git commit -a")

In pythonwhere console, the modified version in the working directory is first stashed through "git stash" and then merge the branch CN-0807 which is pulled back and the local main branch through "git merge".

(myproj) 09:01 ~/django-sample/learning_templates (main)$ git stash
Saved working directory and index state WIP on main: 2325c5c Create README.md
(myproj) 09:02 ~/django-sample/learning_templates (main)$ git merge origin/CN-0807-indexhtmlchange
Updating 2325c5c..1584f5a  
Fast-forward
 learning_templates/learning_templates/settings.py        | 2 +-
 learning_templates/templates/basic_app/index-backup.html | 8 ++++++++
 learning_templates/templates/basic_app/index.html        | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)
 create mode 100644 learning_templates/templates/basic_app/index-backup.html

Glad to hear that you made it work!

Deleted