Skip to main content

Command Palette

Search for a command to run...

Using Git for Version Control on PythonAnywhere

Published
•3 min read•View as Markdown

This is a step step process on how to commit in github using PythonAnywhere Bash console

Initializing Git

  • First go to pythonanywhere.com and login to your account

  • Second go to the Bash console

  • Third list all the directories or folder save on your Bash console to list it use the ls command

  • Fourth go to the directory projects to go or change the directories use cd foldername command

  • Fifth initialize git to initialize it use git init command and to verify it if you have git in your folder use ls -a command so you can see if you have the .git folder

  • Sixth create a new file name project_file.txt to create it use touch project_file.txt command and add it to git staging area to add it use git add . command

  • Seventh commit it using the git commit -m "Initial commit: add project_file.txt" command

Making changes to the file and committing 10 times

  • Modify the file using echo “Change 1” >> project_file.txt command

  • After add it to the git staging area using git add . command or git add project_file.txt command

  • And then commit it using git commit -m "Commit #1: added Change 1" command

  • Then modify the file again using echo "Change 2" >> project_file.txt

  • After add it to the git staging area using git add . command or git add project_file.txt command

  • And then commit it using git commit -m "Commit #2: added Change 2" command

  • Do this process until you get to commit #10

Adding a remote repository and pushing the code to GitHub

  • Now make a Github Repository and then copy the git remote add origin command that you will see it will be like this git remote add origin https://github.com/BrandonLCanete/pythonAnyWhereCommits.git this command will add your github repository so that you can push your code to github

  • But before you push it go to your Github settings find Developer settings and then click the Personal Access Tokens and then click the Tokens (classic) and then find the Generate new token and click the Generate new token (classic) and then when you see note add your token name and then choose the expiration date of your token click the repo part and the next part is for you to decide if you want it or not if you want it click it and if not don’t click it go down and find the Generate Token green button and after that copy the token code and don’t forget it because you will see it only one time you can save it to notepad

  • Now go back to your pythonanywhere bash console and do the git push -u origin master command and now you will see a username input your github username account and enter it after that you will see a password to do it copy your token code and paste it to the bash console and enter it now go back to your github repository and verify it if your code is now push to the github repository

Code Snippet

https://github.com/BrandonLCanete/pythonAnyWhereCommits.git

More from this blog

Cañete,Brandon L.'s team blog

46 posts