Well... I've been working on a blog post about using git on PythonAnywhere. How about I post it here first so you can try it out and give me some feedback?
Git on PythonAnywhere
NB: git is relying on ssh access. And ssh access is a feature of paid accounts only.
PythonAnywhere has web based Bash consoles. We are going to use one of those to
create a git repository. Then on your local machine we are going to clone
it and make a commit. Then push that commit back up to your new private repo on
Now visit your consoles tab and start a fresh Bash session.
Once inside you will be at a prompt that looks something like this and we
can make our first remote repo
<username>@PythonAnywhere:~$ mkdir my_repo.git
<username>@PythonAnywhere:~$ cd my_repo.git
<username>@PythonAnywhere:~$ git init --bare
You can call your repo whatever you want. There are no potential for namespace
collissions because everything is inside your own account.
Now, from your local machine you can clone that repo using
~/:$ git clone <username>@ssh.pythonanywhere.com:my_repo.git
If you haven't added your public key to /home/<username/.ssh/authorized_keys
then this step will ask you for your PythonAnywhere account password.
You can now add a file, make your first commit and push back to
~/:$ cd my_repo
~/:$ touch README.md
~/:$ git add README.md
~/:$ git commit -m"Hello, World!"
~/:$ git push origin master
And that is it! Feel free to set up shared accounts to collaborate with others
or work directly on your repo via our in browser editor.
Some additional tips and hints
Below are a couple more tips for people using PythonAnywhere as their git
The git repo on PythonAnywhere is a bare repo. That means it has no working
tree. You cannot work directly inside it. If you want to hack on your project
directly from PythonAnywhere you will need to do a local clone. From a
PythonAnywhere Bash console run,
<username>@PythonAnywhere:~$ git clone my_repo.git
Then do your work inside my_repo and push back to origin if you want to pull
those changes outside PythonAnywhere.
Your PythonAnywhere git repos work over SSH. To enable pushing and pulling
without having to enter passwords you can add your public key to your account.
There are many ways to do this. But the following commands will work even if
you have never created a Public/Private key pair before. If you have an
existing key pair just skip the ssh-keygen part.
~/:$ ssh-keygen -t rsa
~/:$ ssh-copy-id <username>@ssh.pythonanywhere.com
Another way to make ssh access to a remote server easier is to put some
settings into ~/.ssh/config.
My section for PythonAnywhere looks like this:
This means that if I want to connect to PythonAnywhere all I need to type is
It even autocompletes :)
Another benefit is that I can clone one of my repos from PythonAnywhere with
~/:$ git clone paw:my_repo.git