bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Git/Git and GitHub
Git•Git and GitHub

Git Push to GitHub

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Git Push to GitHub?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ push origin
3Order

Put the learning moves in the order that makes the concept easiest to apply.

Transferring our local changes to our remote is done with a push command.
When we have made changes locally, we want to update our remote repository with the changes.
Git Push to GitHub

When we have made changes locally, we want to update our remote repository with the changes.

Transferring our local changes to our remote is done with a push command.

There are several commands we can use to push changes to GitHub.

Key Push Commands

  • Basic Push
  • Force Push
  • Push Tags
  • Troubleshooting

Basic Push

This command pushes your current branch to the remote repository named origin :

Example

git push origin

This will upload your local commits to GitHub.

You must have already committed your changes with git commit .

Force Push

If your push is rejected due to non-fast-forward updates (for example, after a rebase), you can force the push.

Warning

This can overwrite changes on the remote repository. Use with caution!

Example

git push --force origin feature-branch

Use --force-with-lease for a safer force push:

Example

git push --force-with-lease origin feature-branch

Push Tags

To push all local tags to GitHub:

Example

git push --tags

Example

git push origin v1.0

Troubleshooting

  • Non-fast-forward error: Happens if someone else pushed to the branch. Run git pull --rebase before pushing again.
  • Authentication failed: Make sure you have access to the repository and your credentials are correct.

Go to GitHub, and confirm that the repository has a new commit:

Now, we are going to start working on branches on GitHub.

Previous

Git Pull from GitHub

Next

Git Pull Branch from GitHub