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