RGB logo

RGB Studios.org

A web development company

January 5, 2023

What the -u Flag in Git Does

Justin Golden

Photo credit @synkevych on Unsplash

Length: Short

Level: ✓ Beginner ✓ Intermediate X Advanced


You may have seen the -u flag when reading about git online, such as in git push -u origin master.

The Docs

The -u flag is the same as --set-upstream, which in the git push docs says:

For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull and other commands.


When you push to your local branch with -u, your local branch will be linked to the remote branch.

Specifically, it sets the origin as the upstream remote in your git config.


This means you can use git pull and git push without having to specify arguments each time.


You can always run git push --help to read the docs on the command line, and offline : )

More Blog Articles
  Share   Tweet   Pin   Share   Post   Post   Share   Email