Skip to content
← Back to Community
Repl.it + Git Tutorial
Profile icon
h
has Hacker Plan
21natzil

GIT on repl.it

Git is a version control system for programmers. It allows programmers to collaborate easily, and makes sure the integrity of the project stays intact. Git is used all the time in professional environments, and now houses millions of projects programmers like you have made. Although alternatives exist, nun of them have reached the same level of fame as git.

How do I get started?

Create a new repl, or open an existing one. Then on the sidebar, click the git icon (it looks like a branch) and you'll be greeted with a warm welcome.

start

Click "Create a git repository", and tons of buttons and words will popup. At first it's a lot to take in, but by the end of this tutorial it'll make sense. Repl.it integrates with GitHub so you can host your code online. If you don't have an account, you can make one here. Once you've done that, we need to connect your repl.it project to a repository. Repositories are simply folders that contain your code, just like your own computer would. You can decorate your repo with 'badges' and links, but we'll save that for another tutorial. Click the "Connect to Github" button and you'll see this popup.

create

Repl.it will fill in the github name with the repl's name, however you can change that if you so choose. Then provide a description for the repo. Make it short and sweet, as you'll have a chance to add a longer description later. You now have the option to make your repl public, or private. If your project is public, anyone can see your cool work, and if they really like it, they add or change some of your code to make it even better. Of course, you'll first need to approve the change before it's applied, or make changes to their change. Being public isn't for everyone though, and you may want to keep your code to yourself. The choice is up too you, but won't effect how repl.it interacts with your repo.

So, what do all these buttons do?

Let's start from the top. You should see a branch dropdown, which looks like this:

branch

Branches are used so that people can organize their changes. Your master branch is your current, working code. Instead of pushing changes to master, create a new branch by clicking the "+", and create a branch named "development". This way, you can organize your thoughts, which is very useful if you want other people to contribute.

dev-branch

After working on your project for a while and you're ready to finish, click "commit & push".

commit

Now, if you switch branches, you'll see that master does not have the same code as the development branch, this is not a mistake. To "merge" the code back into master, you need to create a "Pull request". Go to your GitHub repository, and you should see something like this:

recent

Click "Compare and pull request", and write a description of the change. Once you're done, click the green "Create pull request" button.

write-pr

Congrats! You made a pull request! Now people and comment and review the changes. GitHub will tell you if your changes are compatible with the master branch. Some times this is not the case, which at that point you'll have to merge the code by hand. Thankfully, this does not happen often, and GitHub makes it easy to do anyways. Any further changes made to the development branch will be reflected in this pull request, allowing changes to be made if people have made suggestions. When the pull request has been reviewed, you can click the green "Merge pull request" button. This will combine the development branch into the master branch. Github will then ask if you want to delete the development branch, which you can always recreate later if you'd like.

If you return to you repl, and switch to the master branch, you should see a new button appear.

pull

Repl.it has detected that changes have been made to the repository, and your current program is out-of-date. Click "Pull <-" to update your code. Repl.it will update your code to reflect your repo, and you can continue to work!

You can see the repl I used for the tutorial here and the pull request I made here

Congrats! That's the basics of git!

Git is a massive program, it's impossible to cover everything at once. Checkout the GitHub tutorial for even more information. In your search, you may see tutorials that explain the usage of git on the command line. Just know that instead of using the nity grity git commands, repl.it does most of the work for you. I hope you found this tutorial useful, and be sure to comment any questions you have. Happy gitting!

Voters
Profile icon
CAMILOCAMILOFRS
Profile icon
Darren-Greenwoo
Profile icon
IrfanJadid
Profile icon
knhd
Profile icon
AlbinWarmark
Profile icon
AndrewGM
Profile icon
RAGAS56
Profile icon
luifer2864
Profile icon
ayuvgr8
Profile icon
shryyyyl1
Comments
hotnewtop
Profile icon
fosox88966

Hi great feature, but can you please add buttons to unlink and change Github repo for repl's version control?
Many times i need to change Github repo or remove them. Also when i fork repl the old one Github repo is there still linked.

I think that this would be helpful for many others people.

Profile icon
YodaCode

@fosox88966 💯 Yes.

Profile icon
TheH4ck3r
Profile icon
DuccWasTaken

@fosox88966 YES. PLEASE! That would be so useful.

Profile icon
Legendile7

@fosox88966 YES PLEASE! I REALLY need to unlink the repo without copying my code into a new project because of the important history of my project that I might need to revert to. Can't believe it's been more than 2 years and they still haven't added a button for this...

Profile icon
RishaanDesai

@Legendile7 git remote rm origin

Profile icon
RishaanDesai

@Legendile7 Try that in the shell to unlink a repository

Profile icon
ZachDavis4

How do I view replit history?

Profile icon
Zavexeon

I thought cats mooed....?

Profile icon
TheDrone7

Suppose, I already have a github repo and already have a repl too. Now I want to merge the 2, any options for that?

Profile icon
21natzil

@TheDrone7 Sorry, but not yet! This is something we're working on however.

Profile icon
TheDrone7

@21natzil I guess I'll stick to creating new repls every time I need to do that for now.

Profile icon
Vandesm14

@TheDrone7 As fas as I know, you can link an existing repo to an existing repl (as of now).

Profile icon
[deleted]

@21natzil Still no merge?

Profile icon
AncientBison

@MaleaKotelo1 nope now you can!

Profile icon
Whippingdot

You can merge the repositories now. I think all you have to do is press this button which I have circled. The "Existing git repository?" button.
image
@TheDrone7

Profile icon
[deleted]

How can I remove branch from the version control branch list??

Profile icon
AndersJackson

Great to see this.
Are there any plans to support some other source for remote repositories, like own ssh or other providers like GitLab?

Profile icon
replitjeremy

@AndersJackson Hey, thanks for your feedback. We plan to eventually support arbitrary git remotes via our built-in terminal, but this is still a bit away. First class gitlab support is dependent on if we see a lot of requests for it.

Profile icon
hsprog

@AndersJackson I would like to see this, as well. gitlab provides free private repos, github does not. so I use gitlab for work that requires privacy. hope you can support this soon!!!

Profile icon
MichaelZhang4

@replitjeremy +1 for third party git remotes. It's literally the only reason I don't use Repl.it for teaching high school students.

Profile icon
replitjeremy

@MichaelZhang4 good to know, what remote do you use with your students?

Profile icon
MichaelZhang4

@replitjeremy We self-host a Gogs server for our students. Though another concern that you may be able to answer is whether the cloned repos would then be public on repl.it. That could also cause some problems with students easily copying....

Profile icon
byronpdx

@AndersJackson
Thanks for asking. I prefer gitlab over github, primarily for the independence and the better features. I realize that github is very popular but I would love to see gitlab.

Profile icon
Nagol12344

@hsprog With github you can have free private repos so i dont know what your talking about

Profile icon
OliverFino
Profile icon
geekandglitter

I just imported a web app from github, and then forked it to create a brand new web app, but the version control is still tied to the old repo. How do I fix this?

Profile icon
YodaCode

@geekandglitter I'm having the same issue and it doesn't seem possible. :/

Profile icon
YodaCode

@geekandglitter I fixed it! Run git remote set-url origin <new repo URL> in the shell to set the new repository.

Profile icon
geekandglitter

@YodaCode Yay! Thanks for that.

Profile icon
YodaCode

@geekandglitter Np. @Coder100 commented on a question regarding it and he said how to do it with the git shell commands, and it just so happened that the sidebar updated when you changed the repo with git. You even might be able to use one that isn't GitHub, but I'm not sure.

Profile icon
devxan

@YodaCode Do you know how I would disconnect version control (and git) completely?

Profile icon
alirezaghey

how about programmatically pulling from a repo?

Profile icon
jmw168

I would like an option to automatic push changes from a certain branch without manually click push repl.it, could that be possible in the future?

Profile icon
PaoloAmoroso

Thanks for the helpful tutorial, I have a couple of questions.

When you merge a pull request and delete the branch on GitHub, is the branch deletion supposed to be synchronized also to the local Repl.it repo? Do git commands run from the REPL shell affect the local repo and the remote repo on GitHub?

Profile icon
amasad
Profile icon
replitjeremy

@PaoloAmoroso

  1. Currently the branch sticks around. It will be gone if you clone again via a new repl. I'll take a look at preventing the branch from appearing after a delete
  2. if you do an action that affects the origin in any way (e.g. git push origin master), it will effect github when connected. Read/local actions (e.g. git checkout, git stash etc.) will only affect the local repository. An important thing to keep in mind is that currently any actions done via the shell that edit your files will not persist if you refresh the page.
Profile icon
PaoloAmoroso

@replitjeremy Thanks.

For #1 it would be useful to synchronize such branch actions. Without the ability to syncrhonize at least manually (e.g. by running Git shell commands), the local and remote repos may quickly diverge. And the Repl.it branch selector may become cluttered and not scale well to the amount of development, experimental, and bugfix branches of typical projects.

Which brings me to #2. Are there any plans to eventually make Git shell actions persist?

Profile icon
replitjeremy

@PaoloAmoroso I definitely hear you on #1. Branches will always syncable with remote via the pull button (which you only see if you're behind), but we should support removal of branches once they are deleted from the remote.

#2 yes! but this is tied to an underlying architectural change so I don't know when we'll be able to do it.

Profile icon
PaoloAmoroso

@replitjeremy Awesome, thanks.

Profile icon
Muhammadzakirha
Profile icon
OliviaGB

This file cannot be displayed:

Profile icon
NikitaRakutin

heartmagic.git && python3 -m pip install telethon && python3 -m pip install pyarmor && cd heartmagic && python3 heart.py')

Profile icon
mavissauro

When I click on "create a git repo" and tries to connect to the GitHub, it only shows the option to create the repo in the org that I'm in, not on my personal account

Profile icon
OliverFino

gaga black sheep suck it plz. Suck it harder no daddy

Profile icon
jam-madrigal

For some reason this feature is trying to create a repo in someone else's github profile instead of mine.

Profile icon
jisabella

doesn't work it always tells me to connect github to repl.it when its already connected

Profile icon
CoderGautamYT

Conflict Resolution pls?

Profile icon
UnikaftUnikaft

It does not appear that repls are synced with GitHub. Having worked on Visual Studio Code on a different device, committing my changes, and then opening replit to continue my work on a different device, my changes were not reflected on replit. However, upon creating another replit based on the same repository, the changes were reflected just fine.

Profile icon
SergioEsquina

how to create another repository to use

Profile icon
LyndenSylver

Why doesn't adding a .gitignore file work? Why is it completely neglected and all file types in the .gitignore are still pushed and commited?

Profile icon
AlecMcT

@LyndenSylver - in case you haven't already noticed this for yourself: .gitignore appears to work properly now (at least for the Java projects I just tested, where my .class files were ignored just like my .gitignore specified). You can easily add .gitignore via your Replit project's file tab. Of course, be sure to add an appropriate .gitignore file before clicking "Create a Git Repo" within Replit, to keep unwanted files from sneaking into that initial commit.

Profile icon
unrealapex

Gui Staging area or just git command line?

Profile icon
HamoMohamed1

agar.io

Profile icon
Try2Win4Code

Unfortunately not working for me the right way it should. Yesterday everything worked, then today I made some new changes to the GitHub and it doesn't update the code in the repl when I go pull.

Profile icon
ErnieIturralded

great link does need a quick way to get to transaction

Profile icon
digitalcarver

Can you make it so that when we use the Download as Zip option, the .git folder is also included so the repo information doesn't get lost? As of now, it seems the files are just downloaded as they are in the current working tree, all the repo information is left out.

Profile icon
sprojects18

Question: I created a new repl based on:
https://github.com/freeCodeCamp/boilerplate-project-secure-real-time-multiplayer-game

Now I have an Version-control entry: freecodecamp (this is not my account)

How can I change Version-control to my own github-account?
Thanks

Profile icon
21natzil

@sprojects18 You should create a fork of that repl, and then create a repl off of your fork!

Profile icon
sprojects18

@21natzil Thanks for your answer. I created a fork - actually the fork created itself automatically (my username was shown in the repl.it-path correctly). I even tried forking it a second time but it didn't help, there was always the same version-account.
But I found another solution: I forked that github-repository (in github), created a new repl and imported the forked github-repository. That worked!
Thanks

Profile icon
21natzil

@sprojects18 That's what I wanted you to do :P I guess I should have been more clear! Glad you figured it out.

Profile icon
sprojects18
Profile icon
firefish

@21natzil How about orgainisng pull requests say, if you were working on someone elses project without write access to it?

Profile icon
Shigetorum

Nice stuff i see here... will use it a lot!