🎁 Using Git with Repl.it: A Short Guide
I stumbled upon this post, which described a method to access Git commands from within your repl. Using a Version Control System (VCS) like Git is incredibly useful, and even more so when augmented with GitHub.
In the post, the accepted answer recommended using the
os Python module and accessing system commands from there.
import os os.system('git clone') os.chdir('./Sigag') os.system('git status')
I created a little repl that demonstrates this. Make sure you delete the
Sigag directory before starting the program (although it's not a strict requirement). After the clone has finished, I'm able to leave the repl, reopen the repl, and have the Git repository still there.
However, there is a much easier way to use Git commands. In most repls, you're able to enter the shell. Press
F1, and type
shell. Note that with some keyboards, you may need to press
Fn+
F1. (You can also press Ctrl+Shift+p - thanks @ArchieMaclean!)
Now, you can just clone it the usual way.
git clone cd ./Sigag git status
Once the clone has finished, you should see the
Sigag directory in your file tree!
However, the output of
ls and your file tree may be different sometimes. For example, I would type
ls into the shell, and it will show
Sigag as a directory. However, my file tree would only show
main.py. To fix this, simply refresh the page.
It may seem a bit convoluted getting this to work, but easier methods of using git will be introduced at a later date, according to the post below. The screenshot below was taken on the publish date of this guide.
I hope this was helpful 😄. Let me know if this helped you!
The problem is after cloning a repo, it will be cloned into a separate folder. This prevents me from running the
index.js file inside of that repo folder, since repl.it looks for the
index.js located in
/home/runner and not in
/home/runner/repo. Another problem is file updates. After cloning a repo and refreshing the page (to update the file GUI) the repo folder is deleted and the file tree is replaced with the original repl files. Repl.it, please fix this so It will work.
Do you guys maybe know the keys on a chromebook?
I tried Ctrl+Shift+P but it is not working.
I have no FN Key.
I tried to get this to work with my python project.
You can also press
Ctrl
Shift
P(and type
shell) to open the shell, if you don't have the function keys (like me).
@ArchieMaclean Hey, thanks for the tip! I put that in there. I'll edit it in - hopefully it helps out some fine chaps! :)