Way to import code from specific branch of repo?


I noticed that Glitch only seems to import the master branch of my github project, with no option to import the specific branch I am working on and need feedback on. Is there way to import just the code for a specific branch? Sounds like others have asked about this issue before, but I see that was raised last year.


Hi @dennisgit42,

each project has its own git repository (if you just created your project, give it around 10 minutes for it to be created). So if you access the Terminal (Project menu -> Advanced Options -> Terminal) you can add the github project as a remote and then pull the branch you prefer :slight_smile: If you need further guidance let me know!


Hello @etamponi How can I do that you’re mentioning? pulling the branch I prefer :smile:


You would have to use git commands in the console to do that. You can’t do it right now with the GH import function.


How can I do that? I’m doing it this way…


Right now, GH import just pulls the code from GH, not the history of the repository, so you don’t have any branches locally, and the remote hasn’t been set up to point to GH. The best way to do this right now would be to delete your app directory, and clone from GH into that directory.

cd /
rm -rf /app
git clone https:/github.com/<some-project> app
cd app
git checkout <some branch>

This will delete whatever is in your project, so make sure there’s nothing you care about in there.


It just occurred to me that you can’t completely remove the app directory. Instead, do this:

rm -rf /app/*
rm -rf /app/.*


I’m trying to clone a private repository and if I do that like you mention I get this


Maybe try git clone https://[insert username]:[insert password]@github.com/[insert organisation name]/[insert repo name].git


thank you @Gareth , I did a bit different but same; idea: instead of https://username:password@github.com/username/repository.git just https://github.com/username/repository.git and, the console asked for the credentials.

So now it works! thanks! I did like this:

rm -rf /app/*
git clone https::github.com/username/repository.git app
cd app
git checkout the-branch