It's very important to understand that even though the branch looks the same, it's composed of entirely new commits. The second and more common scenario is after an action like a rebase-which changes the commit history: Internally, Git accomplishes by creating new commits and applying them to the specified base. 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.
![git create branch based on current git create branch based on current](https://storage.googleapis.com/cdn.thenewstack.io/media/2018/05/c057fff7-screen-shot-2018-05-17-at-4.18.10-pm.png)
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.
![git create branch based on current git create branch based on current](https://git-scm.com/book/en/v2/images/basic-rebase-1.png)
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.