How to Push Code to GitHub on the Command Line (2024 updated) - with Authentication

Infinite Codes · Intermediate ·🌐 Frontend Engineering ·2y ago

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 Why Python is the BEST programming language (Top 10 2024)
Why Python is the BEST programming language (Top 10 2024)
Infinite Codes
2 The Most Fun Programming Language for Beginners!
The Most Fun Programming Language for Beginners!
Infinite Codes
3 Why Python is the Hottest Programming Language
Why Python is the Hottest Programming Language
Infinite Codes
4 How to delete a repository in GitHub (2024 updated)
How to delete a repository in GitHub (2024 updated)
Infinite Codes
5 How to get OpenAI API key / ChatGPT API key (2024 updated)
How to get OpenAI API key / ChatGPT API key (2024 updated)
Infinite Codes
6 How to clone GitHub Repository (2024 updated)
How to clone GitHub Repository (2024 updated)
Infinite Codes
7 How to Clone GitHub Repository in Visual Studio Code (2024 updated)
How to Clone GitHub Repository in Visual Studio Code (2024 updated)
Infinite Codes
8 How to Push Code to GitHub from Visual Studio Code & Create a GitHub Repository (2024 updated)
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
How to Push Code to GitHub on the Command Line (2024 updated) - with Authentication
Infinite Codes
10 CrewAI Tutorial: Automate your Life with AI Agents
CrewAI Tutorial: Automate your Life with AI Agents
Infinite Codes
11 Automate your Life with AI Agents (EASY CrewAI Tutorial)
Automate your Life with AI Agents (EASY CrewAI Tutorial)
Infinite Codes
12 I Automated my Instagram with AI Agents - CrewAI Hierarchical Tutorial (Instagram Automation)
I Automated my Instagram with AI Agents - CrewAI Hierarchical Tutorial (Instagram Automation)
Infinite Codes
13 How I’d learn Machine Learning & AI in 2024 (if I could start over) -- 7-step Roadmap
How I’d learn Machine Learning & AI in 2024 (if I could start over) -- 7-step Roadmap
Infinite Codes
14 How to Create an EC2 Instance in AWS in 2024
How to Create an EC2 Instance in AWS in 2024
Infinite Codes
15 How to connect CrewAI to different LLMs (GPT4o, Groq, Llama3, Ollama) - Tutorial & LLM comparison
How to connect CrewAI to different LLMs (GPT4o, Groq, Llama3, Ollama) - Tutorial & LLM comparison
Infinite Codes
16 How to Learn Machine Learning in 2024 (7 step roadmap)
How to Learn Machine Learning in 2024 (7 step roadmap)
Infinite Codes
17 How to Use Ollama in 3 minutes -  Run LLMs locally for FREE (LLama3 & more)
How to Use Ollama in 3 minutes - Run LLMs locally for FREE (LLama3 & more)
Infinite Codes
18 How to get a Groq API key - Run LLMs for FREE (LLama3 etc.)
How to get a Groq API key - Run LLMs for FREE (LLama3 etc.)
Infinite Codes
19 What is Groq? - 30 seconds
What is Groq? - 30 seconds
Infinite Codes
20 Perplexity AI Tutorial: Why you don't need Google and ChatGPT anymore
Perplexity AI Tutorial: Why you don't need Google and ChatGPT anymore
Infinite Codes
21 All Machine Learning algorithms explained in 17 min
All Machine Learning algorithms explained in 17 min
Infinite Codes
22 How Math makes Machine Learning easy (and how you can learn it)
How Math makes Machine Learning easy (and how you can learn it)
Infinite Codes
23 15 Machine Learning Lessons I Wish I Knew Earlier
15 Machine Learning Lessons I Wish I Knew Earlier
Infinite Codes
24 Learn Machine Learning Like a GENIUS and Not Waste Time
Learn Machine Learning Like a GENIUS and Not Waste Time
Infinite Codes
25 All Machine Learning Concepts Explained in 22 Minutes
All Machine Learning Concepts Explained in 22 Minutes
Infinite Codes
26 All Machine Learning Beginner Mistakes explained in 17 Min
All Machine Learning Beginner Mistakes explained in 17 Min
Infinite Codes
27 Neural Networks in 100 seconds
Neural Networks in 100 seconds
Infinite Codes
28 Generative AI in 100 seconds
Generative AI in 100 seconds
Infinite Codes
29 GPTs in 100 seconds
GPTs in 100 seconds
Infinite Codes
30 22 Machine Learning Projects That Will Make You A God At Data Science
22 Machine Learning Projects That Will Make You A God At Data Science
Infinite Codes
31 Transformers in 100 seconds
Transformers in 100 seconds
Infinite Codes
32 THIS is Why Machine Learning Is Hard For you
THIS is Why Machine Learning Is Hard For you
Infinite Codes
33 Deep Learning in 100 seconds
Deep Learning in 100 seconds
Infinite Codes
34 30 Machine Learning Facts Most People Get Wrong
30 Machine Learning Facts Most People Get Wrong
Infinite Codes
35 Gradient Descent in 100 Seconds
Gradient Descent in 100 Seconds
Infinite Codes
36 Computer Vision in 100 Seconds
Computer Vision in 100 Seconds
Infinite Codes
37 Reinforcement Learning in 100 Seconds
Reinforcement Learning in 100 Seconds
Infinite Codes
38 32 Machine Learning Facts That Make No Sense
32 Machine Learning Facts That Make No Sense
Infinite Codes
39 What is Machine Learning? Your 2025 Guide to the AI Revolution
What is Machine Learning? Your 2025 Guide to the AI Revolution
Infinite Codes

This video teaches how to create a GitHub repository, clone it on the command line, make changes, and push the changes back to GitHub.com using a Personal Access Token for authentication. It covers the process of generating a PAT, cloning a repository, making changes, committing, and pushing the changes to GitHub.

Key Takeaways
  1. Create a GitHub repository
  2. Generate a Personal Access Token (PAT)
  3. Clone the repository on the command line using HTTPS and the PAT
  4. Make changes to the code
  5. Use 'git add' to stage the changes
  6. Use 'git commit' to commit the changes
  7. Use 'git push' to push the changes to GitHub
💡 Using a Personal Access Token (PAT) is necessary for authentication when cloning a GitHub repository on the command line, as GitHub no longer supports password authentication.

Related AI Lessons

Up next
The masks we wear | Zora Krstić | TEDxLuxembourgCity
TEDx Talks
Watch →