DEV Community

David Loor
David Loor

Posted on • Originally published at davidloor.com on

Git commands to replace a branch with another branch

Git commands to replace a branch with another branch

  1. git branch -m my_feature_branch my_feature_branch_new_name # Rename my_feature_branch
  2. git checkout my_feature_branch_new_name && git push origin my_feature_branch_new_name # Push the backup to the origin, so it is there as reference for other team members.
  3. git checkout master # Checkout to the branch that will replace the my_feature_branch.
  4. git checkout -b my_feature_branch # Create a new my_feature_branch off of the master branch in my example.
  5. git push origin my_feature_branch # It will force to push the new branch to the origin too

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs