
No Comments Yet
Be the first to share your thoughts and start the conversation.
GSAP Course launch discount ends soon!🎉
Claim DiscountBe the first to share your thoughts and start the conversation.
How did you manage to remove the blur property and reach here?
Upgrading gives you access to quizzes so you can test your knowledge, track progress, and improve your skills.
By logging in, you'll unlock full access to this and other free tutorials on JSM Pro.
Why? Logging in lets us personalize your learning experience, track your progress, and keep you in the loop with new workshops, coding tips, and platform updates.
You'll also be the first to know about upcoming launches, events, and exclusive discounts.
No spam—just helpful content to level up your skills.
If that sounds fair, go ahead and log in to continue →
Enter your name and email to get instant access
Git is a tool for tracking changes in projects, while GitHub is an online platform for storing Git repositories and enabling collaboration. This lesson explains how to link a local repository to a remote one and push local changes to GitHub.
git remote add origin <repository-url>
to link your local repository to the remote.git branch -m main
to rename the default branch from master to main.git push -u origin main
to push your local commits to GitHub easily, referring to the remote repository as 'origin'.00:00:00Â Git is a tool you use to track changes, whereas GitHub is a cloud platform that allows you to store your Git repositories online and collaborate with others.
00:00:11Â To push your local project to GitHub, you'll need to link your repository to a remote.
00:00:17Â But what's a remote?
00:00:18Â Well, there are two types of repositories.
00:00:21Â Local Repository is a version of a project that exists on your own machine, laptop, or whatever else you use where you do your developer work.
00:00:30Â When you initialize a repo using Gitinit, you create a local repo in your folder.
00:00:36Â Changes you make there are private until you push them to a remote repository.
00:00:41Â So a remote repo is a version of a project stored on a server like GitHub, GitLab, or Bitbucket.
00:00:49Â It's used to share code between collaborators and keep project versions in sync across different users' computers.
00:00:56Â When collaborating with a team, you'll have two kinds of repos.
00:01:01Â Everyone in the team will have a local repository on their machine.
00:01:05Â And there will also be this one common remote repo from which everyone will sync their local repository versions.
00:01:11Â Now, head over to github.com and create an account if you don't already have one.
00:01:16Â Once you're in, press the little plus icon on the top right and select New Repository.
00:01:22Â Enter a repository name, such as Mastering Git.
00:01:26Â choose whether you want to make it public or private, leave the Add Read Me file checkbox unticked, and click Create Repository.
00:01:37Â This is a remote repository.
00:01:39Â Here, you can see your repository's origin.
00:01:42Â Copy it.
00:01:43Â When you clone a repository from GitHub, Git automatically names the remote repository as origin by default.
00:01:50Â It's basically an alias for the remote repository's URL.
00:01:54Â Now, our goal is to link our local repository to the remote origin.
00:01:58 If you haven't yet switched the default master branch name to main, you can do that by running git branch –m main.
00:02:07Â And this will change the branch name to main, which is a standard practice nowadays.
00:02:11Â And now we are ready to link our local repo to a remote origin.
00:02:16Â You have to run a command git remote add origin and then you have to paste the link to the origin that you just copied and press enter.
00:02:26Â And a good thing to know is that you can have multiple remote repositories.
00:02:30Â You just have to rerun the command and change the origin name to something else.
00:02:36Â Of course, that's the name of your choice, and then you can also update the new URL.
00:02:41Â But in most cases, you'll be fine with just one remote repo.
00:02:44Â Finally, to push your local commits to GitHub, use git push-u origin main.
00:02:52Â And remember, we used origin here to refer to the remote repository instead of typing the full URL.
00:02:59Â So press enter and there we go.
00:03:02Â This worked.
00:03:03Â If anything with Git goes wrong, typically it goes wrong at this point when you're trying to push to a remote repo.
00:03:10Â So if you don't see what I'm seeing right here, and instead you got some error, typically all of these errors are very easily resolvable.
00:03:19Â I would just recommend copying the error message, pasting it in Google, and then fixing it right there and then.
00:03:25Â But in this case, we're good.
00:03:27Â And now, if you go back to your GitHub repository and reload, boom, your code is now online for the world or your team to see.
00:03:37Â And okay, okay, you might have already known this.
00:03:41Â For some of you, that's about as far as you've gone with Git.
00:03:45Â Create a repo, push your changes, and call it a day.
00:03:49Â But Git has so much more to offer, especially when you're working within a team.