How to Push Code to GitHub on the Command Line (2024 updated) - with Authentication
Key Takeaways
The video demonstrates how to create a GitHub repository, clone it on the command line using HTTPS and a Personal Access Token (PAT) for authentication, make changes to the code, and push the changes back to GitHub.com. It covers the process of generating a PAT, cloning a repository, making changes, committing, and pushing the changes to GitHub.
Full Transcript
hey guys so I'm going to show you how to clone a new repository on the command line and then change some code on your computer and push the changes back to gab.com on the command line last time we did that with visual studio today we're going to do it on the command line the main thing I'm going to do differently from other tutorials that are already out there is talking about authentication which people seem to skip over but it is important when you work with private repositories so let's go first if you don't have a GitHub account create one but if you do have one just sign in so let's sign in together send it to your GitHub account and go to your repositories just like last time so if you have a repository you want to clone you can do that but let's go quickly through creating a new repository so let's call it new repo some description make it private because if you can do it for a private one you can definitely do it for a public one and let's add a read me file this is the file we're going to change and then push back github.com create repository so now we have our repo and just like last time what we would do is choose a method of authentication copy the URL of the repository to clipboard so for htps it's this one and then we go to our command line and make sure you have a folder for the repo ready so a destination folder again I'm going to use this GitHub test project folder so we can just go there on the command line by doing CD that's skub and then test project and then we see it's empty and now to clone the repository we're going to type git clone and paste the UR we just copied and here we have to type our GitHub account name and now it's asking for password so GitHub has discontinued the support for your regular PA password authentication uh two years ago I think so now you need to create what is called an authentication token so what you're going to do go up here to settings and then scroll down and go to developer settings and in the developer settings you can go to personal access tokens and classic tokens and here you can generate a new token so let's generate a new classic token and we're going to put a note so token for tutorial you can set an expiration so let's set no expiration and then you can give it some permissions but for the purpose of this tutorial let's just give it the basic repo permissions and then generate the token importantly you can only see this token once so make sure you copy it and save it somewhere maybe in your password manager and then you can go back to the command line and paste the token so make sure you have it saved somewhere because you can only see it once and now we clone the repository so let's do LS the new repost there so let's go in there and there's the read meate file so in the read meate file is the text that was created upon creation of the repo but we want to change it and then push the change back to github.com so let's open it in whatever editor you want I'm going to use visual studio and we're going to add new line of code and we're going to save the file close our editor and then what we can do now is what I like to do first is get status get status will show us what has changed and can potentially be committed so we have the read me f that changed and to Stage it for commit we need to do get ad so that is always the first thing we need to do so get ad you can do get at dot which stages all the files that have changed in the current folder but I like to actually just put the file that changed and be a little bit more specific so let's do that and then we can do get status again and we see now it's in green and it is ready to be committed so the next thing we do after adding is always committing so we do get commit minus M and write a commit message so first change on local machine so this is our commit message we can now hit enter and now we can look get SC status again to always check what's going on there's nothing to commit we committed it and now we can do get push and again our user username and paste the token we just copied and it now pushed it to github.com so let's go and check if the changes have arrived our repositories go to the repo and there you go so the re file now has this line new lines of code which I just wrote if you click here on the commits you can see the last commit has the commit message that was just done first change on local machine this is what we just wrote and we're done
Original Description
How to Push Code to GitHub on the Command Line (2024 updated) - with Authentication
In this video, I will show you how to create a GitHub repository on github.com, and then how to clone the repository on the command line by HTTPS using a Personal Access Token (PAT). I will walk you through changing files in your editor of choice and then committing the changes and then how to push the code from command line to github.
The steps are:
1. Save file
2. Add file to staged changes
3. Write a commit message
4. Commit the staged changes
5. Push changes to GitHub
As opposed to the last video, we will do all of this using the command line / terminal. This will work on Mac, Windows or Linux the same way. It will work for any project / repository hosted on GitHub, regardless if Python, Javascript, React or other project.
Enjoy!
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Infinite Codes · Infinite Codes · 9 of 39
1
2
3
4
5
6
7
8
▶
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Why Python is the BEST programming language (Top 10 2024)
Infinite Codes
The Most Fun Programming Language for Beginners!
Infinite Codes
Why Python is the Hottest Programming Language
Infinite Codes
How to delete a repository in GitHub (2024 updated)
Infinite Codes
How to get OpenAI API key / ChatGPT API key (2024 updated)
Infinite Codes
How to clone GitHub Repository (2024 updated)
Infinite Codes
How to Clone GitHub Repository in Visual Studio Code (2024 updated)
Infinite Codes
How to Push Code to GitHub from Visual Studio Code & Create a GitHub Repository (2024 updated)
Infinite Codes
How to Push Code to GitHub on the Command Line (2024 updated) - with Authentication
Infinite Codes
CrewAI Tutorial: Automate your Life with AI Agents
Infinite Codes
Automate your Life with AI Agents (EASY CrewAI Tutorial)
Infinite Codes
I Automated my Instagram with AI Agents - CrewAI Hierarchical Tutorial (Instagram Automation)
Infinite Codes
How I’d learn Machine Learning & AI in 2024 (if I could start over) -- 7-step Roadmap
Infinite Codes
How to Create an EC2 Instance in AWS in 2024
Infinite Codes
How to connect CrewAI to different LLMs (GPT4o, Groq, Llama3, Ollama) - Tutorial & LLM comparison
Infinite Codes
How to Learn Machine Learning in 2024 (7 step roadmap)
Infinite Codes
How to Use Ollama in 3 minutes - Run LLMs locally for FREE (LLama3 & more)
Infinite Codes
How to get a Groq API key - Run LLMs for FREE (LLama3 etc.)
Infinite Codes
What is Groq? - 30 seconds
Infinite Codes
Perplexity AI Tutorial: Why you don't need Google and ChatGPT anymore
Infinite Codes
All Machine Learning algorithms explained in 17 min
Infinite Codes
How Math makes Machine Learning easy (and how you can learn it)
Infinite Codes
15 Machine Learning Lessons I Wish I Knew Earlier
Infinite Codes
Learn Machine Learning Like a GENIUS and Not Waste Time
Infinite Codes
All Machine Learning Concepts Explained in 22 Minutes
Infinite Codes
All Machine Learning Beginner Mistakes explained in 17 Min
Infinite Codes
Neural Networks in 100 seconds
Infinite Codes
Generative AI in 100 seconds
Infinite Codes
GPTs in 100 seconds
Infinite Codes
22 Machine Learning Projects That Will Make You A God At Data Science
Infinite Codes
Transformers in 100 seconds
Infinite Codes
THIS is Why Machine Learning Is Hard For you
Infinite Codes
Deep Learning in 100 seconds
Infinite Codes
30 Machine Learning Facts Most People Get Wrong
Infinite Codes
Gradient Descent in 100 Seconds
Infinite Codes
Computer Vision in 100 Seconds
Infinite Codes
Reinforcement Learning in 100 Seconds
Infinite Codes
32 Machine Learning Facts That Make No Sense
Infinite Codes
What is Machine Learning? Your 2025 Guide to the AI Revolution
Infinite Codes
More on: Tool Use & Function Calling
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
Next.js vs Remix vs SvelteKit: Which Framework Should You Learn?
Dev.to · Etrit Neziri
Had my Frontend Developer interview with Capgemini (Application Developer) today, and I wanted to…
Medium · JavaScript
10 Frontend Developer Tools to Boost Productivity in 2026
Medium · Programming
10 Frontend Developer Tools to Boost Productivity in 2026
Medium · JavaScript
🎓
Tutor Explanation
DeepCamp AI