Skip to content

TechDirectArchive

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » Version Control System » How to use Command-Line on Git Bash and GitHub Desktop to PUSH local code to GitHub
  • windows server 2019 logo
    How to create a Windows Server reference image using WDS Windows Server
  • Distributed File System DFS
    How to find Dfs Referral Path and clear Dfs referral Cache Storage
  • Feature post
    Disable Bing Search in Windows: Quick Guide for Windows Windows
  • image 35
    How to Activate and Press Ctrl+Alt+Del in Anydesk for Remote Access Connection to Windows system Windows
  • diagnostic6
    How to enable and use Diagnostic Data Viewer on Windows Windows
  • ycx
    Install SysInternals from the Microsoft Store Windows
  • Screenshot 2021 02 01 at 12.25.27
    MySQL Workbench could not connect to MySQL server Oracle/MSSQL/MySQL
  • featured image
    How to Add or Remove Sites from Favorites list in Microsoft Edge 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.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to 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

  • ref error
    Error: cannot lock ref ‘refs/remotes/origin/windows’: unable to resolve reference ‘refs/remotes/origin/windows’, Not a directory Version Control System
  • Deploy Web App from GitHub
    Deploy Code from GitHub to Azure Apps Services via the Command line AWS/Azure/OpenShift
  • coding
    Git GUI and Gitk won’t open “Missing Tcl / Tk Aqua libraries” Version Control System
  • uninstall gtla runner
    How to uninstall GitLab Runner from your Windows device Version Control System
  • git default branch min
    Git config –global init.defaultBranch: Error cannot lock ref ‘refs/remotes/origin/windows’, not a directory Version Control System
  • Screenshot 2022 03 20 at 20.37.16
    Setup HTTPS users using Git credentials and Pushing Code to AWS CodeCommit AWS/Azure/OpenShift

More Related Articles

ref error Error: cannot lock ref ‘refs/remotes/origin/windows’: unable to resolve reference ‘refs/remotes/origin/windows’, Not a directory Version Control System
Deploy Web App from GitHub Deploy Code from GitHub to Azure Apps Services via the Command line AWS/Azure/OpenShift
coding Git GUI and Gitk won’t open “Missing Tcl / Tk Aqua libraries” Version Control System
uninstall gtla runner How to uninstall GitLab Runner from your Windows device Version Control System
git default branch min Git config –global init.defaultBranch: Error cannot lock ref ‘refs/remotes/origin/windows’, not a directory Version Control System
Screenshot 2022 03 20 at 20.37.16 Setup HTTPS users using Git credentials and Pushing Code to AWS CodeCommit AWS/Azure/OpenShift

Leave a Reply Cancel reply

You must be logged in to post a comment.

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

Microsoft MVP

  • windows server 2019 logo
    How to create a Windows Server reference image using WDS Windows Server
  • Distributed File System DFS
    How to find Dfs Referral Path and clear Dfs referral Cache Storage
  • Feature post
    Disable Bing Search in Windows: Quick Guide for Windows Windows
  • image 35
    How to Activate and Press Ctrl+Alt+Del in Anydesk for Remote Access Connection to Windows system Windows
  • diagnostic6
    How to enable and use Diagnostic Data Viewer on Windows Windows
  • ycx
    Install SysInternals from the Microsoft Store Windows
  • Screenshot 2021 02 01 at 12.25.27
    MySQL Workbench could not connect to MySQL server Oracle/MSSQL/MySQL
  • featured image
    How to Add or Remove Sites from Favorites list in Microsoft Edge 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,843 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

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.