You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

How do I push a new local branch to a remote Git repository and track it too?

How do I:

  1. Create a local branch from another branch (via git branch or git checkout -b).

  2. Push the local branch to the remote repository (i.e. publish), but make it trackable so that git pull and git push will work.

Answer

Cancel
2
  • 18
    sometimes your need this git push origin -u local_branch:remote_branch
    – Bruce Lee
    Aug 21, 2018 at 6:28
  • 2
    why does "git push origin -u remote_branch_name " work sometimes and sometimes not?
    – mss
    Jul 26, 2020 at 23:32