Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Contact
  • Reviews
  • Toggle search form
Home » Version Control System » How to use Command-Line on Git Bash and GitHub Desktop to PUSH local code to GitHub
  • Database Connection Stuck on Working on it
    How to fix TeamPass stuck on working on it Network | Monitoring
  • Install Lets Encrypt Certificate on Windows with Certbot
    Install Lets Encrypt Certificate on Windows with Certbot Web Server
  • How to Remove Hyper V
    How to uninstall Hyper-V on a Windows PC Virtualization
  • Windows Admin Center v2   2401 install   2306 to 2311 upgrade
    Upgrade Windows Admin Center 2306 – 2311: Install WACmg 2410 Network | Monitoring
  • Norton 360 Error
    Norton Autofix identified an issue: Fix Norton 360 Installation has encountered an error 8404 on Windows Anti-Virus Solution
  • redirects3endpoint
    How to redirect requests for your bucket’s website endpoint to another bucket or domain AWS/Azure/OpenShift
  • finalelastic
    How to Install and Configure Elasticsearch on Linux  Linux
  • Screenshot 2020 08 14 at 23.03.54
    How to disable Taskbar Web Search in Windows 10 via GPO and Windows Registry Windows

How to use Command-Line on Git Bash and GitHub Desktop to PUSH local code to GitHub

Posted on 06/03/202222/08/2023 Temitope Odemo By Temitope Odemo No Comments on How to use Command-Line on Git Bash and GitHub Desktop to PUSH local code to GitHub
Git Bash

GitHub is a code repository and hosting platform for version control and collaboration. The software GitHub is a Microsoft platform that helps the development team to collaborate on different projects from anywhere in the world. GitHub Desktop is an application that allows you to interact with GitHub using a Graphical User Interface (GUI) instead of using the command line. The git push command is used to transfer or push your commit, this is usually made on your local branch in your computer to a remote repository like GitHub or any other code repository.

If you need to read more on the deployment of codes, code repository, and API requests you can read these: How to clone a repository and install software from GitHub on Windows, Azure DevOps and GitHub integration for Docker and Kubernetes deployment, How to deploy your Angular App to Azure from Visual Studio Code, How to Setup SonarLint in VS Code for your App Project, How to Use Postman with the Amazon Pinpoint API, How to use Postman for your POST Request.

Before you start this task you need to create a GitHub account here.

Using the Command line to PUSH to GitHub

  • First login to GitHub and create a new repository where you will push your code to in GitHub. However, Create a new repository by clicking the + sign and select New repository.
GitHub Desktop
New Repository
  • Nonetheless, Now fill up all the required details like the repository name, a description which is optional, and also make the repository public for this task.
PUSH local code
Create a new Repository
  • After creating your desired repository, you must open a Git Bash. You can download it here if you do not have it installed yet.
  • Now move to the specific path in your local computer where your code is saved locally by typing cd ‘path_name.’ Moreover, The cd commands stand for change directory, which is used to change to the working directory on your system and locate your file.
GitHub
changing Directory

Now initialize the git repository

  • Use git init to initialize the repository. This command is used to create a new empty repository. Furthermore, The ‘.git‘ is created at the top level of your project and places all of the revision information in one place.
Git Bash
Initializing the Repository

Now add the file to the new local repository.

  • Use git add . in your Git bash to add all the files.
GitHub Desktop
Adding Files
  • Use git status in your Git bash to view all the files that will be part of the first commit.
GitHub
Git Status

You can Commit the files in your local repository by writing a commit message.

  • You can create a commit message by writing git commit -m ‘your message’. This commands help to add the change to the local repository. Moreover, The “m” is a flag for a message and help to define the changes that were carried out and the reason for the change.
GitHub Desktop
First Commit
  • Moreover, You can now copy your remote repository’s URL from your GitHub account.

PUSH local code
GitHub Repository URL
  • You will now need to add the URL copied from your remote repo to where your local content from your repository is pushed. Nonetheless, Use this command git remote add origin ‘your_url_name’
  • The “origin” is the remote name while the remote URL in this instance is https://github.com/mastert002/techdirectarchive_repo.git

Now push your code in your local repository to GitHub

  • The command git push –u origin master pushes your local code to GitHub.
  • In the command, the origin is the default remote repository, while the –u is upstream, and the master is the branch.
  • Now fill in your GitHub username and password to complete the push to GitHub
image-8
GitHub Access Authorization

However, If you supply the correct credentials, you will get the below message

image-9
Authentication Succeeded

Nonetheless, Your local repository will be pushed to GitHub Repository successfully

image-10
Files Pushed to GitHub Repo

Moreover, You can now view your files in your GitHub repository.

image-11
GitHub Repository

Using GitHub Desktop to PUSH your local code to GitHub repository.

Furthermore, You can download GitHub Desktop from here. This platform has a Graphical User Interface that can help you to push your code from a local repository to a GitHub repository.

image-12
GitHub Desktop

After installing the GitHub Desktop, you can give it access to your GitHub account.

image-13
Publish Repository
  • Click on Authorize desktop
image-14
Authorize GitHub Desktop
  • Now create a new local repository inside

C:\Users\techdirecharchives\Documents\GitHub

image-15
Creating a New Local Repository
  • Now click on Publish repository and enter the name of your repository. However, This will be automatically created on GitHub, and all your codes inside the local repository will be pushed to the new repository on GitHub.
image-16
Creating the Remote Directory from GitHub Desktop
  • Moreover, When you check your GitHub repository, you will see the new repository created.
image-17
Repository Created

Now move to GitHub Desktop and commit to master

  • However, You can see the files added to the local repository. Nonetheless, You must also write your commit message and click “Commit to master or main.”
image-18


Pushing your main branch from GitHub Desktop to GitHub.

  • Moreover, You can click “Push origin” to publish all your local codes to GitHub.
image-19
Files Pushed Remotely
  • Successfully pushed all codes to GitHub.
image-20
GitHub Repository

I hope you found this blog post on How to use Command-Line and GitHub Desktop to PUSH local code to GitHub interesting and helpful. In case you have any questions do not hesitate to ask in the comment section.

Rate this post

Thank you for reading this post. Kindly share it with others.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Pocket (Opens in new window) Pocket
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
  • Share on Threads (Opens in new window) Threads
  • Share on Nextdoor (Opens in new window) Nextdoor
Version Control System Tags:Git, Git Bash, Github, Remote Access, Repository

Post navigation

Previous Post: Understanding MBAM compliance state and error status
Next Post: Set up and configure Route 53 for your Domain in AWS

Related Posts

  • Banner 1
    How to Deploy a React Application on Netlify Automation
  • install git 1024x512 1
    How to install Git on macOS Version Control System
  • banner
    How to fix Git always asking for my Username and Password Version Control System
  • DevOps GIT Docker Kubernetes
    Azure DevOps: Docker and Kubernetes Deployment with GitHub AWS/Azure/OpenShift
  • banner 1
    Deploying Next.Js App Using Heroku Cloud Application Platform Version Control System
  • s3versioning
    Hosting Static Website and Versioning on AWS S3 AWS/Azure/OpenShift

More Related Articles

Banner 1 How to Deploy a React Application on Netlify Automation
install git 1024x512 1 How to install Git on macOS Version Control System
banner How to fix Git always asking for my Username and Password Version Control System
DevOps GIT Docker Kubernetes Azure DevOps: Docker and Kubernetes Deployment with GitHub AWS/Azure/OpenShift
banner 1 Deploying Next.Js App Using Heroku Cloud Application Platform Version Control System
s3versioning Hosting Static Website and Versioning on AWS S3 AWS/Azure/OpenShift

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a

  • Database Connection Stuck on Working on it
    How to fix TeamPass stuck on working on it Network | Monitoring
  • Install Lets Encrypt Certificate on Windows with Certbot
    Install Lets Encrypt Certificate on Windows with Certbot Web Server
  • How to Remove Hyper V
    How to uninstall Hyper-V on a Windows PC Virtualization
  • Windows Admin Center v2   2401 install   2306 to 2311 upgrade
    Upgrade Windows Admin Center 2306 – 2311: Install WACmg 2410 Network | Monitoring
  • Norton 360 Error
    Norton Autofix identified an issue: Fix Norton 360 Installation has encountered an error 8404 on Windows Anti-Virus Solution
  • redirects3endpoint
    How to redirect requests for your bucket’s website endpoint to another bucket or domain AWS/Azure/OpenShift
  • finalelastic
    How to Install and Configure Elasticsearch on Linux  Linux
  • Screenshot 2020 08 14 at 23.03.54
    How to disable Taskbar Web Search in Windows 10 via GPO and Windows Registry Windows

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,831 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

Active Directory AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.