Git has become a fundamental part of our developers' daily routine that it's hard to remember our lives without it. And yet, most of us use a limited set of commands and options. Today, I want to focus on two commands most developers probably use every day and look at the defaults behind them. and every git push After git commit, git push is probably the second most used command. I don't think I'll teach you anything with this excerpt from the documentation: git commit git push git-push - Update remote refs along with associated objects -- Git documentation git-push - Update remote refs along with associated objects -- Git documentation Git documentation The default options pushes the current branch to the origin remote; it assumes a branch of the same name as the local branch exists on the latter. If it doesn't exist, you need to use -u option to create it. current branch origin -u Also, the default assumes a single upstream named origin. If you want to push the current branch to another upstream, you need to specify it explicitly: single origin git push other_upstream git push other_upstream Likewise, the default assumes pushing to a remote branch with the same name. To push to another branch, we also must specify it along with the upstream. git checkout my_branch git push other_upstream master git checkout my_branch git push other_upstream master git rebase The default git push options are straightforward. The default ones for git rebase aren't the reason why we probably use one of them all the time. git push git rebase git-rebase - Reapply commits on top of another base tip -- Git documentation git-rebase - Reapply commits on top of another base tip -- Git documentation Git documentation Let's try the git rebase command on a simple tree: git rebase A B C D o---o---o---o master \ E F G o---o---o branch1 [HEAD] A B C D o---o---o---o master \ E F G o---o---o branch1 [HEAD] Nothing happens. Or more precisely, "it depends"™. If we didn't set an origin remote, git complains. origin git There is no tracking information for the current branch. Please specify which branch you want to rebase against. There is no tracking information for the current branch. Please specify which branch you want to rebase against. Imagine the following remote repo: A B C D o---o---o---o master \ E F G H o---o---o---o branch1 [HEAD] A B C D o---o---o---o master \ E F G H o---o---o---o branch1 [HEAD] Let's configure the remote and bind the local branch to the remote branch. git fetch git branch --set-upstream-to=origin/branch1 git fetch git branch --set-upstream-to=origin/branch1 If we call rebase again, git tries to apply every commit from the remote branch, starting from the root one. Since H doesn't exist on the local branch, it just adds it to the tip of it. rebase remote H Let's try with master and test again: master git rebase -i master git rebase -i master -i allows rebasing interactively. Here's the proposal. -i pick 5529dc4 E pick 93af602 F pick 7f79811 G pick c6f853b H pick 5529dc4 E pick 93af602 F pick 7f79811 G pick c6f853b H As per the documentation, the command switched branch, got the commits from master, and now applies the commits in the current branch. master The result is the following: A B C D o---o---o---o master \ E F G H o---o---o---o branch1 [HEAD] A B C D o---o---o---o master \ E F G H o---o---o---o branch1 [HEAD] Git is a huge beast. Most developers, including me, only use a fraction of its features. In this post, we described the default of two of the most common Git commands. I hope it sheds some light on them. To go further: To go further: git-push git-rebase The multiple usages of git rebase --onto Why does git rebase with no arguments work the way that it does? What does command 'git rebase' mean when no arguments followed? git-push git-push git-rebase git-rebase The multiple usages of git rebase --onto The multiple usages of git rebase --onto Why does git rebase with no arguments work the way that it does? Why does git rebase with no arguments work the way that it does? What does command 'git rebase' mean when no arguments followed? What does command 'git rebase' mean when no arguments followed? Originally published at A Java Geek on July 27th, 2025 Originally published at A Java Geek on July 27th, 2025 A Java Geek