Push to GitHub
Background
When developing an app, here’s a common approach:
- You’re working with some new code to get it to work
- You don’t want to break your existing code, so you copy your current code to another folder (Folder A) and continue working in Folder B
- If you make a mistake, you just delete Folder B and resume with Folder A
This approach is the idea behind version control. Version control is a process that lets you keep checkpoints of your code so that you can refer back to them if needed.
Git is a widely-used version control system used to manage code. Code managed with Git is called a Git repository.
GitHub is popular hosting service for Git repositories. With GitHub, you can share your code and collaborate with others.
Learn Git: Introduction
Learn how to track changes in your code and switch between different versions with Git, an open-source version control system.Try it for freeInstructions
In your project, initialize a Git repository:
$ git initCheck the status of which files and folders are new or have been edited:
$ git statusTell Git to start tracking your files and folders:
$ git add .If you want to track a single folder or file, use its name:
$ git add app/ $ git add config/routes.rb
Verify that everything was committed correctly:
$ git status
Save the changes you made, with a message describing what changed:
$ git commit -m "Initial commit"
On GitHub, create a new repository with a short, memorable name:
After creating a repository, copy the git commands under the “…or push an existing repository from the command line”, and paste them into the terminal. These commands will add a remote repository, and then push your local repository to the remote repository.
Want to learn more? Check out our course on Git and GitHub.
'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'
Meet the full teamRelated articles
- Article
Set Up with Git and GitHub
Never fear losing work with this professional versioning system - Article
Git Setup for Mac and Windows Computers
Never fear losing work with this professional versioning system - Article
How to Use Git: A Step-by-Step Tutorial
Learn how to use Git efficiently to track changes in your code, collaborate with others, and simplify your development process. Master version control with our step-by-step guide!
Learn more on Codecademy
- Free course
Learn Git: Introduction
Learn how to track changes in your code and switch between different versions with Git, an open-source version control system.Beginner Friendly1 hour - Free course
Using Git for DevOps: Using Git Effectively
Become proficient in Git for DevOps, including repository management, Git commands, GUI, distributed workflows, branching, Git server protocols, and Gitflow.Intermediate1 hour - Course
Learn Git & GitHub
Use our beginner friendly Git course to integrate Git and GitHub and manage versions of your projects using Git branches.With CertificateBeginner Friendly4 hours