[GitHub] How To Push To GitHub | Learn Version Control With Git
Maybe your like
Pushing code to GitHub means to upload your project code to the GitHub.com code-hosting service. In this short article, we'll show you how to do this using Git on the Command Line as well as through a desktop GUI.
The Git Cheat Sheet
No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!
Download Now for FreeHow to Create a Local Repository
First, you need to have a local repository for your actual project code. (If you already have this, skip to the next section below titled "How to Push to GitHub".)
Using Git on the Command Line
Open the command line ("Terminal" on the Mac, "Git Bash" on Windows) and change into your project's base directory. There, you can create a new Git repository:
$ cd projects/my-project $ git initAs a first step, you can add all of your current files to the repository and then bundle these in a commit:
$ git add . $ git commit -m "Initial commit"Using Git in a Desktop GUI
In case you're using a desktop GUI like the Tower Git client, the process is very easy: you can simply drag your project's base folder into Tower and have it create the Git repository for you.
You can then add all files to the Staging Area and make your first commit:
Now, you are ready to push your code to GitHub!
How to Push to GitHub
Before you can upload your code to GitHub, you need to create a remote repository in your GitHub account.
Using Git on the Command Line
If you're working with Git on the Command Line, you'll have to open the GitHub.com interface in your browser. Right on the "Dashboard" view, you can see a button to create a new repository:

Then, on the project's main page, you can use the green "Code" button to reveal the repository's remote URL and copy it to your clipboard:

You can then connect this remote repository to your local Git repository with the following command:
$ git remote add origin <remote repository URL>The final step is to push your changes from your local repository to your new remote repository:
$ git push origin masterUsing Git in a Desktop GUI
In case you're using a desktop GUI like the Tower Git client, you can simply follow these simple steps:
- right-click the "Remotes" section header in the sidebar and select "Add Remote Repository"
- in the dialog, you can enter a name (e.g. "origin") and the remote repo's URL on Github; additionally, you can select your GitHub account
- confirm the dialog and the remote will now be connected with your local repository
- from now on, you can simply use the "Push" button in the toolbar to upload new changes to the remote on GitHub
Learn More
- Check out the chapter Starting with an Unversioned Project in our free online book
Related Questions
- Git vs. GitHub: What is the Difference?
- How to delete folders and files on GitHub
- Using GitHub on the Desktop
- How to delete a branch on GitHub
- How to delete a repository on GitHub
- How to fork a repository on GitHub
- What is a GitHub Gist?
For additional Git-related questions (and answers!), visit our FAQ homepage.
Tag » How To Push In Github
-
GIT Push And Pull Tutorial - DataCamp
-
Adding Locally Hosted Code To GitHub
-
Pushing Commits To A Remote Repository - GitHub Docs
-
Git Guides - Git Push - GitHub
-
How To Push An Existing Project To GitHub - DigitalOcean
-
How To Git Push An Existing Project To GitHub - The Server Side
-
How To Push Code To Github - YouTube
-
Pushing A Project To GitHub - CircleCI
-
How To Push To GitHub - Zapier
-
Git Push | Atlassian Git Tutorial
-
Push To GitHub - Codecademy
-
Pushing To Github - Made Simple Enough For Poets - FreeCodeCamp
-
Git Push Command Explained With Demo [Updated] - Simplilearn
-
Git Push To GitHub - W3Schools