
The first reason is to fix a mistake-although it is probably better to just make a new commit reverting the changes. There are a couple reasons you may want to do this. Normally, you will push to a branch and add to its commit history.īut, there are times when you need to forcefully overwrite the history of a branch. To :johnmosesman/burner-repo.gitįrom the output you can see that the local main branch was pushed to the remote main branch: To :johnmosesman/burner-repo.git In the example below, the origin remote is a GitHub repository, and the current branch is main: (main)$ git remote -v If your current branch is main, the command git push will supply the two default parameters-effectively running git push origin main. The general form of the command is this: $ git push īy default, Git chooses origin for the remote and your current branch as the branch to push. If you run the simple command git push, Git will by default choose two more parameters for you: the remote repository to push to and the branch to push.

This command has a variety of options and parameters you can pass to it, and in this article you'll learn the ones that you will use the most often. The basic command for pushing a local branch to a remote repository is git push.
