Pushing, Pulling, Cloning
Master the commands to push local changes to a remote, pull updates from a remote, and clone existing repositories.
Pushing, Pulling, Cloning is a free DevOps Bootcamp lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Intro to Remote Repositories
So far, we've worked with Git on our local computer. But what if you want to collaborate with others or back up your work online?
This is where remote repositories come in! A remote repository is essentially a version of your project hosted on the internet or a network server.
Platforms like GitHub provide a home for these remote repositories, making collaboration and sharing super easy.
Getting Started: Cloning a Repo
The first step to working with an existing remote repository is to get a copy of it onto your local machine. This process is called cloning.
When you clone a repository, Git downloads all the project files and its complete version history.
It also automatically sets up a connection (called a 'remote') to the original online repository.
How `git clone` Works
To clone a repository, you use the git clone command followed by the repository's URL.
For example, if a repository is at https://github.com/user/my-project.git, you would use:
git clone https://github.com/user/my-project.gitThis command creates a new directory named my-project containing all the project files and a hidden .git directory for version control.
Behind the Scenes of Cloning
When you clone, Git does a few important things:
- It downloads the entire repository history.
- It creates a new local repository for you.
- It automatically creates a remote connection, usually named
origin, pointing back to the URL you cloned from. - It checks out the default branch (often
mainormaster) as your current working branch.
Sending Changes: Pushing
Once you've made changes, added them to the staging area, and committed them locally, you'll want to share these updates with the remote repository.
This process of sending your local commits to the remote is called pushing. It updates the remote repository with your latest work.
The `git push` Command
The basic command for pushing is git push <remote-name> <branch-name>.
<remote-name>: This is usuallyorigin, the default name for the remote repository you cloned from.<branch-name>: This is the name of the local branch you want to push (e.g.,mainorfeature-x).
So, to push your main branch to origin, you'd use: git push origin main
Pushing Your First Commit
Let's simulate making a change and pushing it:
1. Make a change (e.g., create a new file).
echo "My first remote change!" > remote-note.txt2. Stage and commit your change.
git add remote-note.txt
git commit -m "Add note for remote"3. Now, push these local commits to the remote:
git push origin mainYour remote repository on GitHub (or similar) will now reflect these changes!
Getting Remote Changes: Pulling
While you're working, other collaborators might push their changes to the remote repository. To get these updates into your local repository, you need to pull them.
The git pull command is used to fetch changes from a remote repository and then merge them into your current local branch.
When to Pull?
It's a good practice to pull changes frequently, especially:
- Before you start working for the day.
- Before you begin a new task.
- Before pushing your own changes (to avoid merge conflicts).
The command is similar to push: git pull <remote-name> <branch-name>
So, to pull from origin's main branch: git pull origin main
Pulling Remote Updates
Imagine a team member just pushed an update. To get it:
git pull origin mainGit will download any new commits from the main branch on origin and merge them into your local main branch. If there are no new changes, Git will tell you your branch is up to date.
This keeps your local repository synchronized with the remote, ensuring you're always working with the latest version of the project.
Quick Check
You've made some local commits and want to share them with your team via the remote GitHub repository. Which command should you use?
Recap: Remote Control
Great job! You've learned the fundamental commands for interacting with remote repositories:
git clone: To get a copy of a remote repository onto your local machine.git push: To send your local commits to the remote repository.git pull: To fetch and merge updates from the remote repository into your local branch.
These commands are crucial for collaborating with others and keeping your project synchronized online.
Frequently asked questions
Is the “Pushing, Pulling, Cloning” lesson free?
Yes — the full text of “Pushing, Pulling, Cloning” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.
What will I learn in “Pushing, Pulling, Cloning”?
Master the commands to push local changes to a remote, pull updates from a remote, and clone existing repositories. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Pushing, Pulling, Cloning” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- GitHub Account & Repositories
- Pushing, Pulling, Cloning
- Collaborating with Remotes
- Managing Multiple Remotes