- Python Snacks
- Posts
- Using Git Push and Git Pull for your Python Code
Using Git Push and Git Pull for your Python Code
Keep your code under source control by leveraging the most popular version control tool out there: Git
Part 1 of this series discussed how you can start a new git project and make your first commits. Specifically, I discussed the following commands:
git init - Initializes a repository
git add - Tells Git which files to add to the commit (“snapshot”)
git commit - Takes a snapshot of the added files.
Here, I’ll be discussing pushing and pulling commands:
git push (Git documentation)
git pull (Git documentation)
Key Terminology
Git can be confusing especially with terminology, so I’ve outlined what you need to know for this tutorial:
Commit - Create a “snapshot” of the code in its current state.
Push - Synchronize your project on your computer with GitHub.
Pull - Synchronize what’s in GitHub with your project on your computer.
Pushing Code to GitHub
When you “push” code, you’re taking all of your commits (“snapshots”) and sending them to GitHub. Think of this as publishing your work for others to see:

So, let’s say we’re developing a website. You just finished developing some button aesthetics, making it much cleaner. You’ll run the 2 commands to capture the changes (which may look something like this:
[user@user]$ git add button.py
[user@user]$ git commit -m "updated button aesthetics"
[main (root-commit) af438e] updated button aesthetics
1 file changed, 43 insertions(+), 26 deletions(-)
create mode 100644 button.py
Up until this point, you can’t really share your updates with your team. So, you need a way to send it to them not through email. You’ll run the push
command instead, which will take that commit (af438e) and send it to GitHub so your team can see the changes:
[user@user]$ git push
Pulling Code from GitHub
Great, now that your team can see your changes they need a way to bring it down from GitHub. They can do this by running the git pull
command:
[user@user]$ git pull
Slightly modifying the diagram from above to demonstrate visually how this works:

Now, your team can see all of the changes that you made to your button. Similarly, if your co-worker pushed up a change that is a separate from your work on the button, you can run the git pull
command to pull their changes to your local machine.
📧 Join the Python Snacks Newsletter! 🐍
Want even more Python-related content that’s useful? Here’s 3 reasons why you should subscribe the Python Snacks newsletter:
Get Ahead in Python with bite-sized Python tips and tricks delivered straight to your inbox, like the one above.
Exclusive Subscriber Perks: Receive a curated selection of up to 6 high-impact Python resources, tips, and exclusive insights with each email.
Get Smarter with Python in under 5 minutes. Your next Python breakthrough could just an email away.
You can unsubscribe at any time.
Interested in starting a newsletter or a blog?
Do you have a wealth of knowledge and insights to share with the world? Starting your own newsletter or blog is an excellent way to establish yourself as an authority in your field, connect with a like-minded community, and open up new opportunities.
If TikTok, Twitter, Facebook, or other social media platforms were to get banned, you’d lose all your followers. This is why you should start a newsletter: you own your audience.
This article may contain affiliate links. Affiliate links come at no cost to you and support the costs of this blog. Should you purchase a product/service from an affiliate link, it will come at no additional cost to you.
Reply