Sign up
  • Home

  • Productivity

  • App tutorials

App tutorials

2 min read

How to Push to GitHub

By Khamosh Pathak · June 10, 2019
how-to-push-to-github primary img

There are plenty of ways to use GitHub: the website, the app, or the terminal. The terminal is the best way to sync local projects to a GitHub repository, and once you learn the basics, you'll be able to push local projects to remote GitHub repositories in seconds.

Here's how to push to GitHub.

What Does it Mean to Push to GitHub?

Pushing to GitHub means uploading to a GitHub repository.

Maybe you just created a new public repository for a project and you want to upload all your files to it. Or maybe you're continually working on a project from a private GitHub repository for your company, and you want to upload the latest changes that you've made.

How to Push to GitHub

First, you'll need to install and enable Git on your local machine. Use the Git website to learn how to get started.

Once Git is set up, go to the web page for your GitHub repository and note the URL.

Project URL

Now, open Terminal on your Linux or Mac machine (use Bash on Windows).

Open Terminal

Use the cd command to switch to the directory you want to push to the GitHub repository. Then, start the Git process by typing the following command.

git init

Type git init

Next, you'll make your first commit saying that the git process has been initiated.

git commit -m "first commit"

First commit

You've just committed the first Git code locally. Now you'll take it up to your GitHub repo.

Remember the URL of the project? Insert it in the following command and remember to add .git at the end. Before the URL, you'll also want to enter a nickname for the repository so it becomes easier to push to it in the future.

git remote add <project nickname> <project URL>.git

Add remote GitHub repo to local directory

Next, see if it worked by using the following command.

git remote

You can also use the -v or --verbose command, which will print the URL, so you can verify not only that the remote was created, but also that the URL is correct.

You'll see the details of the linked repository.

confirm that it worked

Now, connect the remote repository to the local directory by entering the following command.

git pull origin master

git pull origin master

Now you can push the contents of the directory to the GitHub repository using the following command.

git push -u <project nickname> master

Push local contents to remote repository

This will take all the files and folders from the directory and upload them to the repository. But before it can do that, GitHub needs to authenticate your identity, so you'll need to enter your GitHub username and password. Once the authentication is done, the upload process will start. In a minute or two, you'll see specific details about where the data was uploaded.

And that's it: You've successfully pushed your local files and folders to your GitHub repository.

Open the GitHub repo web page and you'll see all the details there.

See where data was uploaded

Automate GitHub with Zapier

Zapier lets you connect GitHub to thousands of apps, so you can automate more of your Git processes. For example, you could automatically get a notification or create a task in your project management tool whenever there's a new pull request in your repo.

Send new GitHub pull requests to Slack messages

Send new GitHub pull requests to Slack messages
  • GitHub logo
  • Slack logo
GitHub + Slack

Head to our GitHub integrations page for more ideas on how to supercharge GitHub.

Get productivity tips delivered straight to your inbox

We’ll email you 1-3 times per week—and never share your information.

mentioned apps

Related articles

Improve your productivity automatically. Use Zapier to get your apps working together.

Sign up
A Zap with the trigger 'When I get a new lead from Facebook,' and the action 'Notify my team in Slack'