How do I use github to push changes to my flask webserver?

Hi all,

I am new to web development.

Every time I make changes to my application on my local machine, I have to scp the entire app to my server, even if I changed something small.

If I want to just push the changes I made to the app without having to scp the whole app how would I do this using github?

I would have to just update the file on my server for the application to update the changes I made.

The server does not have a passphrase as well.

Again I am new to web development, so any pointers would be great.

2 Replies

@mesand --

First, buy these two books and read them cover-to-cover:

Do all the exercises and experiment a lot…especially with branching and merging.

Once you've done that, you can start on your project at hand:

  • Shut down your application and back it up.
  • Move your application to some other name:
    mv /myapp /mytmpapp
  • Create a repository on GitHub. Note the URL it gives you for remote access.
  • Clone the URL to the original name:
    git clone <URL> /myapp
    You can ignore the warning about having cloned an empty repository…you know that already.

At this point you have two directories:

  • /myapp  is an empty clone of your GitHub repository; and
  • /mytmpapp  contains your app files.

You now have a choice:

  • Copy your app files to the empty repository clone:
    cp -Rp /mytmpapp/* /myapp  -- make sure you do the right thing with invisible files (.file) and symlinks!

-- OR --

  • Copy the git control files to your app directory:
    cp -Rp /myapp/.git /mytmpapp

The choice is up to you. You now have clean up -- depending on the choice you made:

  • rm -rf /mytmpapp

-- OR --

  • rm -rf /myapp; mv /mytmpapp /myapp

You should now be able to do your first commit:

  • cd /myapp; git add -A; git commit -a -m 'Initial commit'

Now push your local repository to the remote:

  • cd /myapp; git push origin master

DANGER WILL ROBINSON! DANGER! DANGER!

In all of this, you need to make sure permissions/ownership are correct otherwise things are not going to work correctly and your app may break when you get done. You need to institute some kind of protection for the directory /myapp/.git so that it is not accessible to web visitors. If you mess up, just delete everything; restore your backup; and start over.

There is no guarantee, expressed or implied, in any of this. You assume ALL the risk in following my advice.

-- sw

Along with the suggested workflow that @stevewi provided, we have some Github guides available that may you find helpful.

I've also added some tags to this post, which should help in adding visibility for other Linode Community members to offer any additional help.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct